Last active
June 7, 2018 02:02
-
-
Save namtx/f8571faab0e75cb6de70d6ecf8451817 to your computer and use it in GitHub Desktop.
adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Encrypter | |
def initialize(key) | |
@key = key | |
end | |
def encrypt(reader, writer) | |
key_index = 0 | |
while not reader.eof? | |
clear_char = reader.getc | |
encrypted_char = clear_char ^ @key[key_index] | |
writer.putc(encrypted_char) | |
key_index = (key_index + 1) % @key.size | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment