Click to See Complete Forum and Search --> : Java and JavaScript.


Leon
08-27-2003, 12:21 PM
I never use before no Java, no JavaScript.
I have a function written on Java and I need to put it to JavaScript.
Who can help me please?
I need to value from field PalmId, generate a key and put in field PalmKey
Help!!
public class CodeGenerator {
public static int getUnlockCode(String palmID){
int resKey=0;
int len=palmID.length();
String newPalmID=""; byte[] arrBytes;
if(len>10){
newPalmID=palmID.substring(0,5)+palmID.substring(len-5);
arrBytes=newPalmID.getBytes();
}else{
arrBytes=palmID.getBytes();
}
for(int i=0;i<arrBytes.length;i++){
resKey+=(((int)arrBytes[i])*i);
}
//return resKey & 0xFFFF;
return resKey;
}
}