encrypt

cipher.encrypt â self Instance Public methods Initializes the Cipher for encryption. Make sure to call #encrypt or #decrypt before using any of the following methods: key=, iv=, #random_key, #random_iv, #pkcs5_keyivgen Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).

final

cipher.final â string Instance Public methods Returns the remaining data held in the cipher object. Further calls to #update or #final will return garbage. This call should always be made as the last call of an encryption or decryption operation, after after having fed the entire plaintext or ciphertext to the Cipher instance. If an authenticated cipher was used, a CipherError is raised if the tag could not be authenticated successfully. Only call this method after setting the aut

iv=

cipher.iv = string â string Instance Public methods Sets the cipher IV. Please note that since you should never be using ECB mode, an IV is always explicitly required and should be set prior to encryption. The IV itself can be safely transmitted in public, but it should be unpredictable to prevent certain kinds of attacks. You may use #random_iv to create a secure random IV. Only call this method after calling #encrypt or #decrypt. If not explicitly set, the OpenSSL default of an

key=

cipher.key = string â string Instance Public methods Sets the cipher key. To generate a key, you should either use a secure random byte string or, if the key is to be derived from a password, you should rely on PBKDF2 functionality provided by OpenSSL::PKCS5. To generate a secure random-based key, #random_key may be used. Only call this method after calling #encrypt or #decrypt.

key_len=

cipher.key_len = integer â integer Instance Public methods Sets the key length of the cipher. If the cipher is a fixed length cipher then attempting to set the key length to any value other than the fixed value is an error. Under normal circumstances you do not need to call this method (and probably shouldn't). See EVP_CIPHER_CTX_set_key_length for further information.

name

cipher.name â string Instance Public methods Returns the name of the cipher which may differ slightly from the original name provided.

padding=

cipher.padding = integer â integer Instance Public methods Enables or disables padding. By default encryption operations are padded using standard block padding and the padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur. See EVP_CIPHER_CTX_set_padding for further information.

pkcs5_keyivgen

cipher.pkcs5_keyivgen(pass [, salt [, iterations [, digest]]] ) â nil Instance Public methods Generates and sets the key/IV based on a password. WARNING: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40, or DES with MD5 or SHA1. Using anything else (like AES) will generate the key/iv using an OpenSSL specific method. This method is deprecated and should no longer be used. Use a PKCS5 v2 key generation method from OpenSSL::PKCS5 instead. Parameters salt must be an 8

random_iv

random_iv() Instance Public methods Generate, set, and return a random iv. You must call cipher.encrypt or cipher.decrypt before calling this method.

random_key

random_key() Instance Public methods Generate, set, and return a random key. You must call cipher.encrypt or cipher.decrypt before calling this method.