Class: OpenSSL::Cipher
- Inherits:
-
Object
- Object
- OpenSSL::Cipher
- Defined in:
- lib/openssl/cipher.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Cipher
Instance Method Summary collapse
-
#random_iv ⇒ Object
Generate, set, and return a random iv.
-
#random_key ⇒ Object
Generate, set, and return a random key.
Instance Method Details
#random_iv ⇒ Object
Generate, set, and return a random iv. You must call cipher.encrypt or cipher.decrypt before calling this method.
54 55 56 57 58 |
# File 'lib/openssl/cipher.rb', line 54 def random_iv str = OpenSSL::Random.random_bytes(self.iv_len) self.iv = str return str end |
#random_key ⇒ Object
Generate, set, and return a random key. You must call cipher.encrypt or cipher.decrypt before calling this method.
46 47 48 49 50 |
# File 'lib/openssl/cipher.rb', line 46 def random_key str = OpenSSL::Random.random_bytes(self.key_len) self.key = str return str end |