加密脚本(ORACLE函数)
2018-01-09 09:44
281 查看
create or replace function encode(str varchar2) return varchar2 is
Result varchar2(20);
len number;
i number;
s varchar2(1);
begin
Result:='';
len:=length(str);
if(len is null) then return(null);
end if;
for i in 1..len
loop
s:=substr(str,i,1);
if (s='0') then Result:=Result||'5'; end if;
if (s='1') then Result:=Result||'0'; end if;
if (s='2') then Result:=Result||'9'; end if;
if (s='3') then Result:=Result||'1'; end if;
if (s='4') then Result:=Result||'3'; end if;
if (s='5') then Result:=Result||'7'; end if;
if (s='6') then Result:=Result||'4'; end if;
if (s='7') then Result:=Result||'8'; end if;
if (s='8') then Result:=Result||'2'; end if;
if (s='9') then Result:=Result||'6'; end if;
end loop;
return(Result);
end encode;
Result varchar2(20);
len number;
i number;
s varchar2(1);
begin
Result:='';
len:=length(str);
if(len is null) then return(null);
end if;
for i in 1..len
loop
s:=substr(str,i,1);
if (s='0') then Result:=Result||'5'; end if;
if (s='1') then Result:=Result||'0'; end if;
if (s='2') then Result:=Result||'9'; end if;
if (s='3') then Result:=Result||'1'; end if;
if (s='4') then Result:=Result||'3'; end if;
if (s='5') then Result:=Result||'7'; end if;
if (s='6') then Result:=Result||'4'; end if;
if (s='7') then Result:=Result||'8'; end if;
if (s='8') then Result:=Result||'2'; end if;
if (s='9') then Result:=Result||'6'; end if;
end loop;
return(Result);
end encode;
相关文章推荐