Merci pour ton aide j'ai corrigé le script comme suit mais toujours pas de résultat. seulement ceci.
désolé cela semble bête.
Resultat:
document.getElementById("demo").innerHTML = rc4("D7FC4711FD5EBDEB","MLA")
ci dessous le code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ExecScript example</title>
<script type="text/javascript">
function rc4(key, text) {
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 < text.length; y++) {
i = (i + 1) % 256;
j = (j + s[i]) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
ct += (text.charCodeAt(y) ^ (s[(s[i] + s[j]) % 256])).toString(16).pad("0", 2).toUpperCase(); /*ct += String.fromCharCode((text.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]));*/
}
return ct;
}
function rc4Decrypt(key, text) {
var 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 = '';
if (0 == (text.length & 1)) {
for (var y = 0; y < text.length; y += 2) {
i = (i + 1) % 256;
j = (j + s[i]) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
ct += String.fromCharCode((parseInt(text.substr(y, 2), 16) ^ s[(s[i] + s[j]) % 256]));
}
}
return ct;
}
/*!
* Post Checksum Calculator
*/
function postChkCalc(str) {
var chk = 0;
for (var i = 0; i < str.length; i++) {
chk += str.charCodeAt(i);
}
return (chk & 0xFFFF).toString(16).pad("0", 4).toUpperCase();
}
/*!
* String Padding Function
*/
String.prototype.pad = function (inC, inL) {
var str = this;
while (str.length < inL) {
str = inC + str;
}
return str;
}
</script>
</head>
<body>
<p>Resultat:</p>
<p id="demo"></p>
document.getElementById("demo").innerHTML = rc4("D7FC4711FD5EBDEB","MLA")
</body>
</html> |
Partager