Encryption and Decryption

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • padmanabhanp
    New Member
    • Nov 2006
    • 14

    Encryption and Decryption

    Hai,
    I am facing one problem in Encryption(Java ). I want to get a string from the user and split that string into characters. After splitting that string into characters, i am changing that character into integer and adding some value to it. what my problem is after adding that value i want change that into String and Store that String in the database.


    Thanks in Advance
  • sivadhas2006
    New Member
    • Nov 2006
    • 142

    #2
    Hi,

    Can you post your java code?

    Regards,
    M.Sivadhas.

    Comment

    • sivadhas2006
      New Member
      • Nov 2006
      • 142

      #3
      Hi,

      Try this..

      Code:
      int i = 10;
      String strTest = Integer.toString(i)
      or 
      String strTest = "" + i
      Regards,
      M.Sivadhas.

      Comment

      • padmanabhanp
        New Member
        • Nov 2006
        • 14

        #4
        Originally posted by sivadhas2006
        Hi,

        Can you post your java code?

        Regards,
        M.Sivadhas.

        import java.io.*;
        import java.lang.*;

        class encrypt1
        {

        public static void main (String args[])
        {

        String name="welcome";
        char ch[]=new char[20];
        int j;
        char c1;
        for(int i=0; i<=name.length( )-1; i++)
        {
        ch[i]=name.charAt(i) ;
        j=ch[i]+5;
        c1=(char)j;
        System.out.prin tln(c1);
        }
        }
        }

        Comment

        • jansi2005
          New Member
          • Nov 2006
          • 2

          #5
          try this code. the changed character is stored in a string.hope it ll be useful. if i havent met ur expectations, pls lemme knw.

          public class testSample {

          public static void main (String args[])
          {
          String name="welcome";
          String str = "";
          char ch[]=new char[name.length()];
          char character[]=new char[name.length()];
          int j;
          char c1;
          for(int i=0; i<=name.length( )-1; i++)
          {
          ch[i]=name.charAt(i) ;
          //System.out.prin tln("char is -----"+ch[i]);
          j=ch[i]+5;
          //System.out.prin tln("j value is ---"+j);
          c1=(char)j;
          character[i]=c1;
          System.out.prin tln("c1 value is---"+c1);
          System.out.prin tln("character array----"+character[i]);
          }
          System.out.prin tln("char array length is---"+ch.length );
          int charLength = character.lengt h;
          for(int i=0; i<charLength-1;i++){
          str= str + character[i];
          }
          System.out.prin tln("the string is---"+str);
          }
          }

          Comment

          • padmanabhanp
            New Member
            • Nov 2006
            • 14

            #6
            Hai,

            Thanks a Lot. I got the exact output.

            Originally posted by jansi2005
            try this code. the changed character is stored in a string.hope it ll be useful. if i havent met ur expectations, pls lemme knw.

            public class testSample {

            public static void main (String args[])
            {
            String name="welcome";
            String str = "";
            char ch[]=new char[name.length()];
            char character[]=new char[name.length()];
            int j;
            char c1;
            for(int i=0; i<=name.length( )-1; i++)
            {
            ch[i]=name.charAt(i) ;
            //System.out.prin tln("char is -----"+ch[i]);
            j=ch[i]+5;
            //System.out.prin tln("j value is ---"+j);
            c1=(char)j;
            character[i]=c1;
            System.out.prin tln("c1 value is---"+c1);
            System.out.prin tln("character array----"+character[i]);
            }
            System.out.prin tln("char array length is---"+ch.length );
            int charLength = character.lengt h;
            for(int i=0; i<charLength-1;i++){
            str= str + character[i];
            }
            System.out.prin tln("the string is---"+str);
            }
            }

            Comment

            Working...