PolarDB-O is compatible with Oracle databases and provides the MD5 functions and stored procedures of the DBMS_OBFUSCATION_TOOLKIT package.
Usage notes
When you create a PolarDB-O database for a PolarDB-O cluster created on or after March 30, 2020, the DBMS_OBFUSCATION_TOOLKIT plug-in is automatically created.
When you create a PolarDB-O database for a PolarDB-O cluster created before March 30, 2020, the DBMS_OBFUSCATION_TOOLKIT plug-in is not automatically created. To use the plug-in, you must execute the following statement to manually create the plug-in after you create the database:
CREATE EXTENSION polar_dbms_obfuscation_toolkit;
For more information about the plug-in, see DBMS_OBFUSCATION_TOOLKIT.
Interfaces
Interface | Type | Data type of the input parameter | Data type of the output |
---|---|---|---|
dbms_obfuscation_toolkit.md5 | Function | BYTEA | RAW_CHECKSUM |
dbms_obfuscation_toolkit.md5 | Stored procedure | BYTEA | RAW_CHECKSUM |
dbms_obfuscation_toolkit.md5 | Function | CHARACTER VARYING | CHARACTER VARYING |
dbms_obfuscation_toolkit.md5 | Stored procedure | CHARACTER VARYING | CHARACTER VARYING |
Usage method
-- Run the MD5 functions.
select dbms_obfuscation_toolkit.md5('a'::varchar2);
select dbms_obfuscation_toolkit.md5('a'::raw);
-- Run the stored procedures.
exec dbms_obfuscation_toolkit.md5(input=>'a');
exec dbms_obfuscation_toolkit.md5(input_string=>'a');
-- Use the MD5 algorithm to encrypt data in the stored procedure.
declare
input varchar2(100):= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
checksum1 raw(100);
checksum2 varchar2(100);
begin
dbms_obfuscation_toolkit.md5(input=>utl_raw.cast_to_raw(input), checksum=>checksum1);
dbms_obfuscation_toolkit.md5(input_string=>input, checksum_string=>checksum2);
dbms_output.put_line(checksum1);
dbms_output.put_line(utl_raw.cast_to_raw(checksum2));
end;