Class: OpenSSL::Cipher

Inherits:
Object
  • Object
show all
Defined in:
lib/openssl/cipher.rb

Direct Known Subclasses

Cipher

Defined Under Namespace

Classes: Cipher

Instance Method Summary collapse

Instance Method Details

#random_ivObject

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_keyObject

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