Encription in Oracle | | here is a simple program is wrote for one of my projects to encript data in Oracle.
create or replace function estring(p_var varchar2)
return varchar2
is
v_estr varchar2(255);
v_elength number;
ipos number;
xor number;
begin
--Ensure password IS NOT case-sensitive
p_var := lower(p_var);
--Only encrypt IF parameter IS NOT NULL
if p_var is not null then
v_elength := length(p_var);
-- CREATE the KEY using a combination the the lenth OF the password +
the pos of the 3rd char found in the PW.
xor := v_elength + instr(p_var, substr(p_var, 3, 1));
ipos := 1;
v_estr := '';
while ipos <= v_elength loop
v_estr := v_str || to_char(to_ascii(substr(p_var, ipos, 1)) ^ xor);
ipos := ipos + 1;
end loop;
return(v_estr);
else
v_estr := null;
return(v_estr);
end if;
end estring |