message = 'Hello, world!'
key = 4
def encrypt(message, key)
return message.split('').map{ |c| c = (c.ord + key).chr }.join
end
def decrypt(cipher, key)
return cipher.split('').map{ |c| c = (c.ord - key).chr }.join
end
cipher_text = encrypt(message, key)
plain_text = decrypt(cipher_text, key)
puts "#{message} encrypted with key value of #{key}:"
puts cipher_text
puts "#{cipher_text} deciphered with key value of #{key}:"
puts plain_text
bWVzc2FnZSA9ICdIZWxsbywgd29ybGQhJwprZXkgPSA0CgpkZWYgZW5jcnlwdChtZXNzYWdlLCBrZXkpCiAgcmV0dXJuIG1lc3NhZ2Uuc3BsaXQoJycpLm1hcHsgfGN8IGMgPSAoYy5vcmQgKyBrZXkpLmNociB9LmpvaW4KZW5kCgpkZWYgZGVjcnlwdChjaXBoZXIsIGtleSkKICByZXR1cm4gY2lwaGVyLnNwbGl0KCcnKS5tYXB7IHxjfCBjID0gKGMub3JkIC0ga2V5KS5jaHIgfS5qb2luCmVuZAoKY2lwaGVyX3RleHQgPSBlbmNyeXB0KG1lc3NhZ2UsIGtleSkKcGxhaW5fdGV4dCAgID0gZGVjcnlwdChjaXBoZXJfdGV4dCwga2V5KQoKcHV0cyAiI3ttZXNzYWdlfSBlbmNyeXB0ZWQgd2l0aCBrZXkgdmFsdWUgb2YgI3trZXl9OiIKcHV0cyBjaXBoZXJfdGV4dAoKcHV0cyAiI3tjaXBoZXJfdGV4dH0gZGVjaXBoZXJlZCB3aXRoIGtleSB2YWx1ZSBvZiAje2tleX06IgpwdXRzIHBsYWluX3RleHQ=