DBMS_CRYPTO v12

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 following 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.
HASH(src)RAWApplies a hash algorithm to CLOB 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, Advanced Server will not return error ORA-28233 if you re-encrypt previously encrypted information.

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

decrypt encrypt hash mac randombytes randominteger randomnumber