The ISAAC cipher: Difference between revisions
Content deleted Content added
Line 2,442: | Line 2,442: | ||
macro static function mix(a:ExprOf<Ub4>, b:ExprOf<Ub4>, c:ExprOf<Ub4>, d:ExprOf<Ub4>, |
macro static function mix(a:ExprOf<Ub4>, b:ExprOf<Ub4>, c:ExprOf<Ub4>, d:ExprOf<Ub4>, |
||
e:ExprOf<Ub4>, f:ExprOf<Ub4>, g:ExprOf<Ub4>, h:ExprOf<Ub4>) { |
e:ExprOf<Ub4>, f:ExprOf<Ub4>, g:ExprOf<Ub4>, h:ExprOf<Ub4>) { |
||
return macro { |
return macro { |
||
$a ^= $b << 11; $d += $a; $b += $c; |
$a ^= $b << 11; $d += $a; $b += $c; |
||
Line 2,463: | Line 2,463: | ||
while (i < 256) { /* fill in mm[] with messy stuff */ |
while (i < 256) { /* fill in mm[] with messy stuff */ |
||
if (flag) { /* use all the information in the seed */ |
if (flag) { /* use all the information in the seed */ |
||
a += randrsl[i]; b += randrsl[i + 1 |
a += randrsl[i]; b += randrsl[i + 1]; |
||
c += randrsl[i + 2]; d += randrsl[i + 3]; |
|||
e += randrsl[i + 4]; f += randrsl[i + 5]; |
|||
g += randrsl[i + 6]; h += randrsl[i + 7]; |
|||
} |
} |
||
mix(a, b, c, d, e, f, g, h); |
mix(a, b, c, d, e, f, g, h); |
||
Line 2,471: | Line 2,473: | ||
i += 8; |
i += 8; |
||
} |
} |
||
if (flag) { |
if (flag) { /* do a second pass to make all of the seed affect all of mm */ |
||
i = 0; |
i = 0; |
||
while (i<256) { |
while (i<256) { |
||
Line 2,516: | Line 2,518: | ||
} |
} |
||
public function caesar(m:Ciphermode, ch:Int32, shift:Int32, |
public function caesar(m:Ciphermode, ch:Int32, shift:Int32, |
||
modulo:Int32, start:Int32):String { |
|||
var n:Int32; |
var n:Int32; |
||
if (m == mDecipher) n = ch - start - cast(shift,Int32); |
if (m == mDecipher) n = ch - start - cast(shift,Int32); |
||
Line 2,527: | Line 2,530: | ||
public function caesarStr(m:Ciphermode, msg:String, modulo:Int32, start:Int32):String { |
public function caesarStr(m:Ciphermode, msg:String, modulo:Int32, start:Int32):String { |
||
var c = ""; |
var c = ""; |
||
for (i in 0...msg.length) |
for (i in 0...msg.length) |
||
c += caesar(m,msg.charCodeAt(i),iRandA(),modulo,start); |
|||
return c; |
return c; |
||
} |
} |
||
Line 2,556: | Line 2,560: | ||
} |
} |
||
} |
} |
||
</lang> |
</lang> |
||
{{out}} |
{{out}} |