Skip to content

Instantly share code, notes, and snippets.

View SamMeeDee's full-sized avatar

Sam Davenport SamMeeDee

View GitHub Profile
@SamMeeDee
SamMeeDee / onetimepad.rb
Last active April 28, 2017 01:28
A class containing methods that can be used to run additive and subtractive one-time pad operations, both on characters and strings.
# These methods are all class methods. To convert to instance methods, remove the "self." portion of the method names.
# In order to decrypt, utilize the opposite method you used to encrypt, and pass the method the encrypted text, followed by the key.
# You can use these methods to determine the key used to encrypt if you have both the plain text and ciphertext.
# - If an additive method was used to encrypt, call the subtractive method, passing in the ciphertext, followed by the plaintext
# - If a subtractive method was used to encrypt, call the subtractive method, passing in the plaintext, followed by the ciphertext
class OneTimePad