Class: Ciphers::Aes
- Inherits:
-
Object
- Object
- Ciphers::Aes
- Defined in:
- lib/crypto-toolbox/ciphers/aes.rb
Instance Method Summary collapse
- #decipher_cbc(key_str, input_str, iv: nil) ⇒ Object
-
#decipher_ecb(key, input) ⇒ Object
NOTE convert ECB encryption to AES gem or both to openssl.
- #encipher_cbc(key_str, input_str, iv: nil) ⇒ Object
- #encipher_ecb(key, input) ⇒ Object
-
#initialize(key_size: 128) ⇒ Aes
constructor
A new instance of Aes.
Constructor Details
#initialize(key_size: 128) ⇒ Aes
Returns a new instance of Aes.
4 5 6 7 8 |
# File 'lib/crypto-toolbox/ciphers/aes.rb', line 4 def initialize(key_size: 128) @key_size = key_size @block_size_bits = 128 @block_size_bytes = 16 end |
Instance Method Details
#decipher_cbc(key_str, input_str, iv: nil) ⇒ Object
23 24 25 |
# File 'lib/crypto-toolbox/ciphers/aes.rb', line 23 def decipher_cbc(key_str,input_str,iv: nil) unicipher_cbc(:decipher,key_str,input_str,iv) end |
#decipher_ecb(key, input) ⇒ Object
NOTE convert ECB encryption to AES gem or both to openssl
11 12 13 |
# File 'lib/crypto-toolbox/ciphers/aes.rb', line 11 def decipher_ecb(key,input) decipher_ecb_blockwise(CryptBuffer(key),CryptBuffer(input).chunks_of(@block_size_bytes)) end |
#encipher_cbc(key_str, input_str, iv: nil) ⇒ Object
19 20 21 |
# File 'lib/crypto-toolbox/ciphers/aes.rb', line 19 def encipher_cbc(key_str,input_str,iv: nil) unicipher_cbc(:encipher,key_str,input_str,iv) end |
#encipher_ecb(key, input) ⇒ Object
15 16 17 |
# File 'lib/crypto-toolbox/ciphers/aes.rb', line 15 def encipher_ecb(key,input) encipher_ecb_blockwise(CryptBuffer(key),CryptBuffer(input).chunks_of(@block_size_bytes)) end |