FirebirdSQL logo

DECRYPT()

Decrypts data using a symmetric cipher

Result type

VARBINARY or BLOB

Syntax
DECRYPT ( encrypted_input
  USING <algorithm> [MODE <mode>]
  KEY key
  [IV iv] [<ctr_type>] [CTR_LENGTH ctr_length]
  [COUNTER initial_counter] )

!! See syntax of <<fblangref50-scalarfuncs-encrypt,ENCRYPT>> for further rules !!
Table 1. DECRYPT Function Parameters
Parameter Description

encrypted_input

Encrypted input as a blob or (binary) string

See [fblangref50-scalarfuncs-tbl-encrypt] for other parameters

Note
  • Sizes of data strings (like encrypted_input, key and iv) must meet the requirements of the selected algorithm and mode.

  • This function returns BLOB SUB_TYPE BINARY when the first argument is a BLOB, and VARBINARY for all other text and binary types.

  • When the encrypted data was text, it must be explicitly cast to a string type of appropriate character set.

  • The ins and outs of the various algorithms are considered beyond the scope of this language reference.We recommend searching the internet for further details on the algorithms.

DECRYPT Examples

select decrypt(x'0154090759DF' using sober128 key 'AbcdAbcdAbcdAbcd' iv '01234567')
  from rdb$database;
select decrypt(secret_field using aes mode ofb key '0123456701234567' iv init_vector)
  from secure_table;