Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

OpenSSL::Cipher#final

() -> ::String
cipher.final → string

Returns the remaining data held in the cipher object. Further calls to Cipher#update or Cipher#final are invalid. This call should always be made as the last call of an encryption or decryption operation, after having fed the entire plaintext or ciphertext to the Cipher instance.

When encrypting using an AEAD cipher, the authentication tag can be retrieved by auth_tag after final has been called.

When decrypting using an AEAD cipher, this method will verify the integrity of the ciphertext and the associated data with the authentication tag, which must be set by auth_tag= prior to calling this method. If the verification fails, CipherError will be raised.

See also #encrypt #iv= #decrypt #iv_len also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0