Introducing the Encrypt gem

require 'encrypt'

encrypted = Encrypt.dump 'super sekret message', 'passw0rd'
  #=> "\x04\b[\b\"\x15\xEC\xD9O\xAE\xA7\x87\x91\x91\xF6\"\x168\x04\xE6\a\xA2\"\x15\x18iF\x9A5\x19G\xAA\xAAa\xC1\xC8\x06\x1A{T\"%8a\xFC&q2n\xB7\x8C\xA8\xD1\xAE\xEE\xEF\xDB\x94\xD4i\t\x1Coy\xA9\xEC\xEC\x1F\x1D\x0E\x9As\x85\xA9"

Encrypt.load encrypted, 'passw0rd'
#=> "super sekret message"

Encrypt.load encrypted, 'wrong'
  #=> OpenSSL::Cipher::CipherError: bad decrypt

Resources

Tags:
Source:
1412hrs.txt
Published:
12-02-2014 14:12