Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/The-ISAAC-Cipher/Sidef/the-isaac-cipher.sidef
Normal file
20
Task/The-ISAAC-Cipher/Sidef/the-isaac-cipher.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require('Math::Random::ISAAC');
|
||||
|
||||
func xor_isaac(key, msg) {
|
||||
var rng = %s<Math::Random::ISAAC>.new(unpack('C*', key));
|
||||
|
||||
msg.chars»ord»() \
|
||||
-> »^« 256.of{ rng.irand % 95 + 32 }.last(msg.len).reverse \
|
||||
-> «%« '%02X' -> join;
|
||||
}
|
||||
|
||||
var msg = 'a Top Secret secret';
|
||||
var key = 'this is my secret key';
|
||||
|
||||
var enc = xor_isaac(key, msg);
|
||||
var dec = xor_isaac(key, pack('H*', enc));
|
||||
|
||||
say "Message: #{msg}";
|
||||
say "Key : #{key}";
|
||||
say "XOR : #{enc}";
|
||||
say "XOR dcr: #{pack('H*', dec)}";
|
||||
Loading…
Add table
Add a link
Reference in a new issue