| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Mailing Lists -> Oracle-L -> Re:RE: Encrypt data
Well for those NOT using 8i try this:
create or replace package encrypt as
function code(inp_data varchar2, key varchar2 default '<something>') return varchar2;
pragma restrict_references(code, RNDS, WNDS, WNPS);
end;
/
create or replace package body encrypt is
function convbin(c1 varchar2) return varchar2 is
loop1 number;
value number;
divis number;
r1 varchar2(30);
begin
r1 := '';
divis := 128;
value := ascii(c1);
for loop1 in 0..7 loop
if(trunc(value/divis) = 1) then
r1 := r1||'1';
else
r1 := r1||'0';
end if;
value := mod(value, divis);
divis := divis/2;
end loop;
return r1;
function code(inp_data varchar2, key varchar2 default 'vicorwestcor') return varchar2 is
loop1 number;
loop11 number;
r1 varchar2(8);
r2 varchar2(8);
key1 varchar2(4000);
r3 number;
result varchar2(40);
divis number;
begin
key1 := key;
while (length(inp_data) > length(key1)) loop
key1 := key1||key1;
end loop;
result := '';
for loop1 in 1..length(inp_data) loop
r1 := convbin(substr(inp_data,loop1,1));
r2 := convbin(substr(key1,loop1,1));
divis := 128;
r3 := 0;
for loop11 in 1..8 loop
if(to_number(substr(r1,loop11,1))+to_number(substr(r2,loop11,1)) = 1)
then
r3 := r3+divis;
end if;
divis := divis/2;
end loop;
result := result||chr(r3);
end loop;
return result;
grant execute on encrypt to public;
create public synonym encrypt for system.encrypt;
NOTE: I put it in under system, but you can put it in under any schema.
Dick Goulet
____________________Reply Separator____________________Subject: RE: Encrypt data
I heard, though never tried, that Oracle 8i has an enciprtion/decription package for such purposes. If you use Oracle 8i, you should check this out in the documentation.
Regards,
Tamas Szecsy
-----Original Message-----
Sent: Friday, October 06, 2000 12:30 PM
To: Multiple recipients of list ORACLE-L
Hi !
I'd like to store some encrypted data in a table.
Is there any standard way to automate the encryption/decription process for
these fields, or should
I develop a encryptor/decriptor function that can manage this ?
Thanks in advance
Gyula Andor
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Andor Gyula
INET: gy.andor_at_euromacc.hu
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may Received on Fri Oct 06 2000 - 09:14:08 CDT
![]() |
![]() |