Thank you for your answer, I wrote this function:
CREATE FUNCTION fhatmp.hash(INSTR VARCHAR(52))
RETURNS CHAR(52)
DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
BEGIN ATOMIC
DECLARE REVSTR, RESTSTR VARCHAR(4000) DEFAULT '';
DECLARE LEN INT;
DECLARE LENE INT;
DECLARE i INT;
declare sm int default 5;
IF INSTR IS NULL THEN
RETURN NULL;
END IF;
IF INSTR ='' THEN
RETURN '';
END IF;
SET (RESTSTR, LEN, LENE) = (hex(INSTR),LENGTH(hex(INSTR)),LENGTH(rtrim(INSTR) ));
WHILE LEN > 10 DO
SET (REVSTR, RESTSTR, LEN)
= (SUBSTR(RESTSTR, 1, 1),
SUBSTR(RESTSTR, 2, LEN - 1),
LEN - 1);
if REVSTR='1' then
set (sm) = (sm +3);
end if;
if REVSTR='2' then
set (sm) = (sm +7);
end if;
if REVSTR='3' then
set (sm) = (sm +11);
end if;
if REVSTR='4' then
set (sm) = (sm +13);
end if;
if REVSTR='5' then
set (sm) = (sm +17);
end if;
if REVSTR='6' then
set (sm) = (sm +19);
end if;
if REVSTR='7' then
set (sm) = (sm +23);
end if;
if REVSTR='8' then
set (sm) = (sm +29);
end if;
if REVSTR='9' then
set (sm) = (sm +31);
end if;
if REVSTR='0' then
set (sm) = (sm +37);
end if;
if REVSTR='A' then
set (sm) = (sm +37);
end if;
if REVSTR='B' then
set (sm) = (sm +37);
end if;
if REVSTR='C' then
set (sm) = (sm +37);
end if;
if REVSTR='D' then
set (sm) = (sm +37);
end if;
if REVSTR='E' then
set (sm) = (sm +37);
end if;
if REVSTR='F' then
set (sm) = (sm +37);
end if;
END WHILE;
set (i,RESTSTR)=(0, rtrim(cast(sm as char(52))));
while (i < LENE) do
set (i,REVSTR)=(i+1,REVSTR||RESTSTR);
end while;
RETURN (substr(REVSTR,1,lene));
END