private static native String rc4Encrypt(String key, String pt) /*-{
function rc4Encrypt1(key, pt) {
s = new Array();
for (var i=0; i<256; i++) {
s[i] = i;
}
var j = 0;
var x;
for (i=0; i<256; i++) {
j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
}
i = 0;
j = 0;
var ct = '';
for (var y=0; y
j = (j + s[i]) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
ct += String.fromCharCode(pt.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
}
return ct;
}
return rc4Encrypt1(key, pt);
}-*/;
0 comments:
Post a Comment