By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,470 Members | 1,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,470 IT Pros & Developers. It's quick & easy.

Encryption and Decryption

P: 14
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
Nov 23 '06 #1
Share this Question
Share on Google+
5 Replies


sivadhas2006
100+
P: 142
Hi,

Can you post your java code?

Regards,
M.Sivadhas.
Nov 23 '06 #2

sivadhas2006
100+
P: 142
Hi,

Try this..

Expand|Select|Wrap|Line Numbers
  1. int i = 10;
  2. String strTest = Integer.toString(i)
  3. or 
  4. String strTest = "" + i
  5.  
  6.  
Regards,
M.Sivadhas.
Nov 23 '06 #3

P: 14
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.println(c1);
}
}
}
Nov 23 '06 #4

P: 2
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.println("char is -----"+ch[i]);
j=ch[i]+5;
//System.out.println("j value is ---"+j);
c1=(char)j;
character[i]=c1;
System.out.println("c1 value is---"+c1);
System.out.println("character array----"+character[i]);
}
System.out.println("char array length is---"+ch.length);
int charLength = character.length;
for(int i=0; i<charLength-1;i++){
str= str + character[i];
}
System.out.println("the string is---"+str);
}
}
Nov 24 '06 #5

P: 14
Hai,

Thanks a Lot. I got the exact output.

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.println("char is -----"+ch[i]);
j=ch[i]+5;
//System.out.println("j value is ---"+j);
c1=(char)j;
character[i]=c1;
System.out.println("c1 value is---"+c1);
System.out.println("character array----"+character[i]);
}
System.out.println("char array length is---"+ch.length);
int charLength = character.length;
for(int i=0; i<charLength-1;i++){
str= str + character[i];
}
System.out.println("the string is---"+str);
}
}
Nov 24 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.