Из - за чего эта ошибка? Гугление не дало четкого ответа.
Вот что хром выдает.
encryption.js:9 Uncaught TypeError: key.charCodeAt is not a function
at rc4 (encryption.js:9)
at Object.success (encryption.js:91)
at i (jquery_min.js:2)
at Object.fireWith [as resolveWith] (jquery_min.js:2)
at A (jquery_min.js:4)
at XMLHttpRequest. (jquery_min.js:4)
at Object.send (jquery_min.js:4)
at Function.ajax (jquery_min.js:4)
at generate_gen_and_simple_mod (encryption.js:76)
at HTMLFormElement.onsubmit ((index):66)rc4 @ encryption.js:9success @ encryption.js:91i @ jquery_min.js:2fireWith @ jquery_min.js:2A @ jquery_min.js:4(anonymous function) @ jquery_min.js:4send @ jquery_min.js:4ajax @ jquery_min.js:4generate_gen_and_simple_mod @ encryption.js:76onsubmit @ (index):66
// RC4
function rc4(key, data_str) {
var s = [], j = 0, x, res = '';
for (var i = 0; i < 256; i++) {
s[i] = i;
}
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;
for (var y = 0; y < data_str.length; y++) {
i = (i + 1) % 256;
j = (j + s[i]) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
res += String.fromCharCode(data_str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
}
return res;
}
$.ajax({
async: false,
type: 'POST',
url: '127.0.0.1',
data: msg,
success: function(data) {
// generate secret key
var degree = Math.pow(data, private_number);
var secret_key = degree % simple_mod;
// get auth data
var get_login = $("input[name='AuthLogin']").val();
var get_pass = $("input[name='AuthPass']").val();
get_login = rc4(secret_key, get_login);
get_pass = rc4(secret_key, get_pass);