I was trying to search for this options and found it Oracle Conversion for Hex functions.
Decimal to Hex function
CREATE OR REPLACE FUNCTION dec2hex (N IN NUMBER) RETURN VARCHAR2 IS
H VARCHAR2(64) :='';
N2 INTEGER := N;
BEGIN
LOOP
SELECT RAWTOHEX(CHR(N2))||H
INTO H
FROM dual;
N2 := TRUNC(N2 / 256);
EXIT WHEN N2=0;
END LOOP;
RETURN H;
END dec2hex ;
Hex to Decimal function in Oracle
CREATE OR REPLACE FUNCTION hex2dec (hexnum IN CHAR) RETURN NUMBER IS
i NUMBER;
digits NUMBER;
result NUMBER := 0;
current_digit CHAR(1);
current_digit_dec NUMBER;
BEGIN
digits := LENGTH(hexnum);
FOR i IN 1..digits LOOP
current_digit := SUBSTR(hexnum, i, 1);
IF current_digit IN ('A','B','C','D','E','F') THEN
current_digit_dec := ASCII(current_digit) - ASCII('A') + 10;
ELSE
current_digit_dec := TO_NUMBER(current_digit);
END IF;
result := (result * 16) + current_digit_dec;
END LOOP;
RETURN result;
END hex2dec;
And to convert simple ASCII String to Hex String you can use.
sql>select rawtohex('0123456789') from dual;
output
RAWTOHEX
----------------
30313233343536373839
Very useful for developer want to encode string of ASCII value to Hex
It internally first converts ASCII String Value of '0' to 48 in decimal value later converts 48 decimal value to hex value as 0x30