How to convert MD5 hash value to Base64 value
jthomps8Sep 10 2010 — edited Sep 13 2010Hello,
I need to convert a string of characters to MD5, then convert that to Base64. For example, I have a string that looks like this:
EX123123456100.00
In my pl/sql, the following code successfully converts the string to MD5:
CREATE OR REPLACE FUNCTION f_get_hash_val (p_in VARCHAR2)
RETURN VARCHAR2
IS
l_hash VARCHAR2 (2000);
BEGIN
l_hash :=RAWTOHEX(UTL_RAW.cast_to_raw(DBMS_OBFUSCATION_TOOLKIT.md5 (input_string=> p_in)));
RETURN l_hash;
END;
/
The output of this function is the MD5 hash value:
231cd7f8e0151f6e0c4a60b33752a1e7
Now I need to encode this MD5 hash value (which is in hex format) to a Base64 value, which should look like this:
IxzX+OAVH24MSmCzN1Kh5w==
Thanks in advance for your help.
Jeanne