Module: Rmega::Crypto::AesEcb
- Included in:
- Rmega::Crypto
- Defined in:
- lib/rmega/crypto/aes_ecb.rb
Instance Method Summary collapse
Instance Method Details
#aes_ecb_cipher ⇒ Object
4 5 6 |
# File 'lib/rmega/crypto/aes_ecb.rb', line 4 def aes_ecb_cipher OpenSSL::Cipher::AES.new(128, :ECB) end |
#aes_ecb_decrypt(key, data) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rmega/crypto/aes_ecb.rb', line 16 def aes_ecb_decrypt(key, data) cipher = aes_ecb_cipher cipher.decrypt cipher.padding = 0 cipher.key = key return cipher.update(data) + cipher.final end |
#aes_ecb_encrypt(key, data) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rmega/crypto/aes_ecb.rb', line 8 def aes_ecb_encrypt(key, data) cipher = aes_ecb_cipher cipher.encrypt cipher.padding = 0 cipher.key = key return cipher.update(data) + cipher.final end |