Published in: Ruby
First things First you need to install this ruby gem user$ sudo gem install ezcrypto
############################ #1. Encryption ############################ #A. Import the Libraries require 'rubygems' require 'ezcrypto' #B. Create AES 128-bit Key # => 1. Make a strong alpha-numeric password longer then 8-bytes # => 2. Create a Salt or two-form hash @key = EzCrypto::Key.with_password("alph@_num3r1c", "salted hash") #C. Encrypt the Data @encrypted = @key.encrypt "$up3r_p@$$w0rd" puts "This is your encrypted data \n" + @encrypted ############################ #2. Decryption ############################ #A. Establish the Key like you did in Step A above #B. Decrypt the Original Message @decrypted = @key.decrypt @encrypted puts "This is the decrypted original data \n" + @decrypted
Comments
Subscribe to comments
You need to login to post a comment.

hello friend
i used ezcrpto for password generation in my rails app , and its not get stored in mysql db giving charset error
here is the error
ActiveRecord::StatementInvalid (Mysql::Error: Illegal mix of collations (latin1swedishci,IMPLICIT) and (utf8generalci,COERCIBLE) for operation '=': SELECT * FROM users WHERE (users.
status= 'active' AND users.password= '/s&µ^õÍZ&Ó£ÿà' AND users.email= 'kumar.bakal@betterlabs.net') LIMIT 1):thanks in advance reguard chetanM