learncrypto/source/cipher.d
2016-02-14 11:00:28 +01:00

28 lines
547 B
D

module cipher;
private import std.range : isInputRange, ElementType;
private import salsa20;
private import chacha20;
public:
enum Cipher {
salsa20,
chacha20
}
auto cipherFunction(R)(R range, ubyte[32] key, ubyte[8] nonce, Cipher cipher)
if(isInputRange!R && is(ElementType!R : ubyte))
{
final switch(cipher)
{
case Cipher.salsa20:
return salsa20Cipher(range, key, nonce);
break;
case Cipher.chacha20:
return salsa20Cipher(range, key, nonce);
break;
}
}