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
|
<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;
}
document.getElementById("demo").innerHTML = rc4(D7FC4711FD5EBDEB,MLA)
// -->
</script>
</head>
<body>
<p>Resultat:</p>
<p id="demo"></p>
</body>
</html> |
Partager