OOS_UTIL_CRYPTO

Constants

Name Code Description
gc_hash_md4
gc_hash_md4 constant pls_integer := 1;
gc_hash_md5
gc_hash_md5 constant pls_integer := 2;
gc_hash_sh1
gc_hash_sh1 constant pls_integer := 3;
gc_hash_sh224
gc_hash_sh224 constant pls_integer := 11;
gc_hash_sh256
gc_hash_sh256 constant pls_integer := 4;
gc_hash_sh384
gc_hash_sh384 constant pls_integer := 5;
gc_hash_sh512
gc_hash_sh512 constant pls_integer := 6;
gc_hash_ripemd160
gc_hash_ripemd160 constant pls_integer := 15;
gc_hmac_md4
gc_hmac_md4 constant pls_integer := 0;
gc_hmac_md5
gc_hmac_md5 constant pls_integer := 1;
gc_hmac_sh1
gc_hmac_sh1 constant pls_integer := 2;
gc_hmac_sh224
gc_hmac_sh224 constant pls_integer := 10;
gc_hmac_sh256
gc_hmac_sh256 constant pls_integer := 3;
gc_hmac_sh384
gc_hmac_sh384 constant pls_integer := 4;
gc_hmac_sh512
gc_hmac_sh512 constant pls_integer := 5;
gc_hmac_ripemd160
gc_hmac_ripemd160 constant pls_integer := 14;
gc_encrypt_des
gc_encrypt_des constant pls_integer := 1;

HASH Function

Generates hash with raw values
See oos_util_crypto.hash_str to handle wrapping

Syntax

function hash(
  p_src raw,
  p_typ pls_integer)
return raw

Parameters

Name Description
p_src
p_typ see oos_util_crypto.gc_hash* variables

Example

select
  rawtohex(
    oos_util_crypto.hash(
      p_src => sys.utl_raw.cast_to_raw('hello'),
      p_typ => 4 -- oos_util_crypto.gc_hash_sh256
    )
  ) example
from dual
;

EXAMPLE
2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824

HASH_STR Function

Generates hash

Syntax

function hash_str(
  p_src varchar2,
  p_typ pls_integer)
  return varchar2

Parameters

Name Description
p_src
p_typ see oos_util_crypto.gc_hash* variables
return Hex hashed value as a string

Example

select
  oos_util_crypto.hash_str(
    p_src => 'hello',
    p_typ => 4 -- oos_util_crypto.gc_hash_md5
  ) example
from dual
;

EXAMPLE
2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824

MAC Function

Generates mac
Note: see mac_str for string inputs

Syntax

function mac(
  p_src raw,
  p_typ pls_integer,
  p_key raw )
return raw

Parameters

Name Description
p_src
p_typ see oos_util_crypto.gc_hmac* variables
p_key secret key

Example

select
  rawtohex(
    oos_util_crypto.mac(
      p_src => utl_raw.cast_to_raw('hello'),
      p_typ => 3, -- oos_util_crypto.gc_hmac_sh256
      p_key => utl_raw.cast_to_raw('abc')
    )
  ) example
from dual
;

EXAMPLE
F3166A3A404599D2046ED2AAE479B37D54B51D2E85259C9E314042753BE7D813

MAC_STR Function

Generates mac with string input / output

Syntax

function mac_str(
  p_src varchar2,
  p_typ pls_integer,
  p_key varchar2 )
  return varchar2

Parameters

Name Description
p_src
p_typ see oos_util_crypto.gc_hmac* variables
p_key secret key
return mac hex value as varchar2

Example

select
  oos_util_crypto.mac_str(
    p_src => 'hello',
    p_typ => 3, -- oos_util_crypto.gc_hmac_sh256
    p_key => 'abc'
  ) example
from dual
;

EXAMPLE
F3166A3A404599D2046ED2AAE479B37D54B51D2E85259C9E314042753BE7D813