Skip to content
instance method

OpenSSL::Cipher#auth_tag

(?::Integer tag_len) -> ::String
cipher.auth_tag(tag_len = 16) → String

Gets the generated authentication tag. This method is available for AEAD ciphers, and should be called after encryption has been finalized by calling final.

The returned tag will be tag_len bytes long. Some cipher modes require the desired length in advance using a separate call to auth_tag_len=, before starting encryption.

See also the “AEAD Interface” section of the man page EVP_EncryptInit(3). This method internally calls EVP_CIPHER_CTX_ctrl() with EVP_CTRL_AEAD_GET_TAG.