core :: union_find
union–find algorithm using an efficient disjoint-set data structure
module repeating_key_xor_solve is example
import base64
import crapto
# Check usage
if args.length != 1 then
print "Usage: repeating_key_xor_solve <cipher_file>"
exit 1
end
# Read the cipher from the file
var cipher_bytes = args[0].to_path.read_all_bytes.decode_base64
# Create a RepeatingKeyXorCipher object to manipulate your ciphertext
var xorcipher = new RepeatingKeyXorCipher
xorcipher.ciphertext = cipher_bytes
# Try to find the best candidate key
xorcipher.find_key
# Decrypt the cipher according to the found key
xorcipher.decrypt
# Check the resulting plaintext out...
print xorcipher.plaintext
lib/crapto/examples/repeating_key_xor_solve.nit:15,1--40,25