DBMS_CRYPTO v16

The DBMS_CRYPTO package provides functions and procedures that allow you to encrypt or decrypt RAW, BLOB, or CLOB data. You can also use DBMS_CRYPTO functions to generate cryptographically strong random values.

The table lists the DBMS_CRYPTO functions and procedures.

Function/procedureReturn typeDescription
DECRYPT(src, typ, key, iv)RAWDecrypts RAW data.
DECRYPT(dst INOUT, src, typ, key, iv)N/ADecrypts BLOB data.
DECRYPT(dst INOUT, src, typ, key, iv)N/ADecrypts CLOB data.
ENCRYPT(src, typ, key, iv)RAWEncrypts RAW data.
ENCRYPT(dst INOUT, src, typ, key, iv)N/AEncrypts BLOB data.
ENCRYPT(dst INOUT, src, typ, key, iv)N/AEncrypts CLOB data.
HASH(src, typ)RAWApplies a hash algorithm to RAW data.
MAC(src, typ, key)RAWReturns the hashed MAC value of the given RAW data using the specified hash algorithm and key.
MAC(src, typ, key)RAWReturns the hashed MAC value of the given CLOB data using the specified hash algorithm and key.
RANDOMBYTES(number_bytes)RAWReturns a specified number of cryptographically strong random bytes.
RANDOMINTEGER()INTEGERReturns a random integer.
RANDOMNUMBER()NUMBERReturns a random number.

DBMS_CRYPTO functions and procedures support the following error messages:

ORA-28239 - DBMS_CRYPTO.KeyNull

ORA-28829 - DBMS_CRYPTO.CipherSuiteNull

ORA-28827 - DBMS_CRYPTO.CipherSuiteInvalid

Unlike Oracle, EDB Postgres Advanced Server doesn't return error ORA-28233 if you reencrypt previously encrypted information.

RAW and BLOB are synonyms for the PostgreSQL BYTEA data type. CLOB is a synonym for TEXT.

decrypt encrypt hash mac randombytes randominteger randomnumber