The ISAAC cipher: Difference between revisions

Content added Content deleted
(Updated D entry)
Line 478: Line 478:
Improved from the C# version. XOR with decryption check.
Improved from the C# version. XOR with decryption check.
<lang d>import std.algorithm: min;
<lang d>import std.algorithm: min;
import std.algorithm: copy;
import std.typetuple: TypeTuple;
import std.typetuple: TypeTuple;
import std.algorithm: copy;
import std.typecons: staticIota;


template Iota(uint stop) { // For manual loop unrolling.
static if (stop <= 0)
alias Iota = TypeTuple!();
else
alias Iota = TypeTuple!(Iota!(stop - 1), stop - 1);
}



struct ISAAC {
struct ISAAC {
Line 542: Line 534:


// Scramble it.
// Scramble it.
/*static*/ foreach (immutable i; Iota!4)
/*static*/ foreach (immutable i; staticIota!(0, 4))
mix(a);
mix(a);