1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 if args
.length
!= 1 then
20 print
"Usage: repeating_key_xor_solve <cipher_file>"
24 # Read the cipher from the file
25 var cipher_bytes
= args
[0].to_path
.read_all_bytes
.decode_base64
27 # Create a RepeatingKeyXorCipher object to manipulate your ciphertext
28 var xorcipher
= new RepeatingKeyXorCipher
29 xorcipher
.ciphertext
= cipher_bytes
31 # Try to find the best candidate key
34 # Decrypt the cipher according to the found key
37 # Check the resulting plaintext out...
38 print xorcipher
.plaintext