Подскажите, пожалуйста, как мне этого добиться (от Oracle до Postgres).
Для этих следующих функций.
ENCRYPTION
PROCEDURE sp_encrypt
(
i_ustring IN VARCHAR2,
o_estring OUT VARCHAR2
)
IS
crypt_part VARCHAR2(10);
BEGIN
o_estring := NULL;
FOR pos in 1..length(i_ustring)
loop
crypt_part := NULL;
crypt_part := utl_raw.bit_xor(HEXTORAW(utl_raw.cast_to_raw(SUBSTR(i_ustring,pos,1))),HEXTORAW(fn_num_to_hex(MOD(pos,256))));
if length(crypt_part)<2
then
crypt_part := '0'||crypt_part;
end if;
o_estring := o_estring||crypt_part;
end loop;
o_estring := utl_raw.cast_to_varchar2(utl_raw.reverse(utl_raw.cast_to_raw(o_estring)));
END sp_encrypt;
DECRYPTION
PROCEDURE sp_decrypt
(
i_estring IN VARCHAR2,
o_ustring OUT VARCHAR2
)
IS
estring VARCHAR2(32767);
crypt_part VARCHAR2(10);
pos NUMBER;
BEGIN
estring := utl_raw.cast_to_varchar2(utl_raw.reverse(utl_raw.cast_to_raw(i_estring)));
pos := 1;
FOR cnt in 1..length(estring)/2
loop
crypt_part := NULL;
crypt_part := CHR(fn_hex_to_num(utl_raw.bit_xor(HEXTORAW(SUBSTR(estring,pos,2)),HEXTORAW(fn_num_to_hex(MOD(NVL(LENGTH(o_ustring),0)+1,256))))));
o_ustring := o_ustring||crypt_part;
pos:=pos+2;
end loop;
END sp_decrypt;