Let me start off by saying Im new to this whole Java thing.
All right, heres my problem:
public String encryptIt(String txt,int key)
{
int len = txt.length();int dx;String xi;
String numstr = "";Random r2=new Random();
char chararray[] = txt.toCharArray();
for(int i=0;i<len;i++)
{
int beef = (int)(r2.nextDouble()*10+1);
xi=giveLets(beef);
dx=(int)chararray;
dx=dx<<key;
dx=dx^key;
numstr+=dx+xi;
}
return numstr;
}
this method works fine sending a different random number to beef each time...the problem however lies in the method called giveLets():
private String giveLets(int many)
{
String d="";int x;char p;Random r1 = new Random();
for(int i=0;i<many;i++)
{
x=(int)(r1.nextDouble()*126+34);
x=(x>=48&&x<=59)?x+20:x;x=(x>128)?x-35:x;
p=(char)x;d+=p;
}
return d;
}
the first (some random number of times I call it, the letters it returns are the same... after that it ends up changing the string...please help me someone!!
also are there any regular expressions in Java? and does anyone know a good online reference?
jared@aauser.com
All right, heres my problem:
public String encryptIt(String txt,int key)
{
int len = txt.length();int dx;String xi;
String numstr = "";Random r2=new Random();
char chararray[] = txt.toCharArray();
for(int i=0;i<len;i++)
{
int beef = (int)(r2.nextDouble()*10+1);
xi=giveLets(beef);
dx=(int)chararray;
dx=dx<<key;
dx=dx^key;
numstr+=dx+xi;
}
return numstr;
}
this method works fine sending a different random number to beef each time...the problem however lies in the method called giveLets():
private String giveLets(int many)
{
String d="";int x;char p;Random r1 = new Random();
for(int i=0;i<many;i++)
{
x=(int)(r1.nextDouble()*126+34);
x=(x>=48&&x<=59)?x+20:x;x=(x>128)?x-35:x;
p=(char)x;d+=p;
}
return d;
}
the first (some random number of times I call it, the letters it returns are the same... after that it ends up changing the string...please help me someone!!
also are there any regular expressions in Java? and does anyone know a good online reference?
jared@aauser.com