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