Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Last active April 14, 2017 11:16
Show Gist options
  • Save thomasjslone/ca4fcffa7d482884f2a18ca23a75bf81 to your computer and use it in GitHub Desktop.
Save thomasjslone/ca4fcffa7d482884f2a18ca23a75bf81 to your computer and use it in GitHub Desktop.
class Simpleton_Cipher
def initialize ; @chset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,./;'[]-=<>?:\"{}_+)(|\\*&^%$#@!~` \n" ; end
def generate_key ; key = @chset ; key = key.split('').shuffle.join('').to_s ; key ; end
def encode(str,key) ; str.tr(@chset, key) ; end
def decode(str,key) ; str.tr(key, @chset) ; end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment