Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • In Addition to previous note, following grants needed on PERFSTAT user. Oracle
  • How to find who is using which Rollback segment and how many rows or blocks in that rollback segments, Oracle
  • Identical Dblink Issue… Oracle
  • how to find VIP from ifconfig Linux/Unix
  • fdisk -l explaination about Primary-Logical-Extended Partitions Linux/Unix
  • Load SPM baseline from AWR Oracle
  • Deleting first line and lastline of a file using sed Linux/Unix
  • Good link for LIO in Oracle ( Logical IOs) Oracle
  • Processes Parameter decision Oracle
  • Oracle 10g Installation/Applying Patches Tips Oracle
  • Linux CPU info. Linux/Unix
  • eplan.sql Oracle
  • shutdown linux Linux/Unix
  • Absolute file number and relative file number Oracle
  • Very Good Oralce Internal Tuning Book Oracle

VIvek Encryption Package and Its Usage

Posted on 18-Nov-2005 By Admin No Comments on VIvek Encryption Package and Its Usage

create or replace package subs_cipher

is

function scramble ( obfs_in varchar2 ) return varchar2;

— pragma not required as of 8.1.5

pragma restrict_references( scramble, wnds, wnps, wnps);

function unscramble ( obfs_in varchar2 ) return varchar2;

— pragma not required as of 8.1.5

pragma restrict_references( unscramble, wnds, rnds, wnps );

end;

create or replace package body subs_cipher

is

— character translation sets

— second set must be identical to first, but in a different order

—

xlate_from varchar2(100) := ‘0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&*()-_=+’;

xlate_to varchar2(100) := ‘PQRtsuLTU%^VWvJYcd0eifghNl(9O&*-_~A1+xC!D=E6jSIKr$@k#n7Fm23ZB45wy8GHM)Xopqzab’;

— how many pieces should text be broken into

v_chunks integer := 4;

— reverse the order of text sent

function reverse ( forward_in varchar2 ) return varchar2

is

v_reverse varchar2(4000) := null ;

begin

v_reverse := ”;

for pos in 1 .. length ( forward_in )

loop

v_reverse := v_reverse || substr( forward_in, 0 – pos, 1);

end loop;

return v_reverse;

end;

— chop the text sent into v_chunks pieces of equal length,

— plus any remainder, then reorder the chunks

function chopit ( text_in varchar2 ) return varchar2

is

v_mod integer;

v_chunk_len integer;

v_chop varchar2(4000);

v_text_length integer;

begin

v_text_length := length(text_in);

if v_text_length < ( v_chunks + 1 ) then
if mod(v_text_length,2) = 0 then

return substr(text_in, (v_text_length / 2) + 1 ) || substr(text_in, 1,v_text_length / 2);

else

return reverse(text_in);

end if;

end if;

— get the remainder

v_mod := mod(length(text_in), v_chunks);

v_chunk_len := (length(text_in) – v_mod) / v_chunks;

v_chop := ”;

if v_mod > 0 then

v_chop := reverse(substr(text_in,0-v_mod));

end if;

v_chop := v_chop

|| substr(text_in, ( v_chunk_len * 2 ) + 1, v_chunk_len ) –3

|| substr(text_in, 1, v_chunk_len ) –1

|| substr(text_in, ( v_chunk_len * 3 ) + 1, v_chunk_len ) –4

|| reverse(substr(text_in, v_chunk_len + 1, v_chunk_len )); –2

return v_chop;

end;

— reverse text chopped by chopit

function unchop ( text_in varchar2 ) return varchar2

is

v_mod integer;

v_chunk_len integer;

v_chop varchar2(4000);

v_text_length integer;

begin

v_text_length := length(text_in);

if v_text_length < ( v_chunks + 1 ) then
if mod(v_text_length,2) = 0 then

return substr(text_in, (v_text_length / 2) + 1 ) || substr(text_in, 1,v_text_length / 2);

else

return reverse(text_in);

end if;

end if;

v_mod := mod(length(text_in),v_chunks);

v_chunk_len := (length(text_in) – v_mod) / v_chunks;

v_chop := ”;

if v_mod > 0 then

–v_chop := reverse(substr(text_in,1,v_mod));

v_chop := reverse(substr(text_in,1,v_mod));

end if;

v_chop :=

substr(text_in, v_chunk_len + v_mod + 1, v_chunk_len ) –1

|| reverse(substr(text_in, ( v_chunk_len * 3 ) + v_mod + 1, v_chunk_len )) –2

|| substr(text_in, v_mod + 1, v_chunk_len ) –3

|| substr(text_in, ( v_chunk_len * 2 ) + v_mod + 1, v_chunk_len ) –4

|| v_chop; — remainder

return v_chop;

end;

function scramble ( obfs_in varchar2 ) return varchar2

is

begin

return translate( reverse(chopit(obfs_in)) , xlate_from, xlate_to );

end;

function unscramble ( obfs_in varchar2 ) return varchar2

is

begin

return translate( unchop(reverse(obfs_in)) , xlate_to, xlate_from );

end;

END subs_cipher;

/

—————- USAGE —————————

update cif_address set street_Address_1=vivek.subs_cipher.scramble(subs_cipher.scramble(street_address_1)) where street_address_1 is not null;

commmit;

update cif_address set street_Address2=subs_cipher.scramble(vivek.subs_cipher.scramble(street_address2)) where street_address2 is not null;

commit;

update cif_address set street_Address3=subs_cipher.scramble(vivek.subs_cipher.scramble(street_address3)) where street_address3 is not null;

commit;

Oracle, SQL scripts

Post navigation

Previous Post: create database link syntax
Next Post: Gathering statistics with DBMS_STATS

Related Posts

  • Oracle Standby Database Library Index from Metalink Oracle
  • pvm_metric.sql for gathering report from vmstat tables Oracle
  • How to Use DBMS_STATS to Move Statistics to a Different Database Oracle
  • Generating XML from SQLPLUS Oracle
  • Oracle 11g RAC on OEL 5 and Vmware 2 Oracle
  • Oracle 10g for solaris 10 Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Good RAC & Standby Notes Oracle
  • 751131.1 New Article Error 2819 While Requesting a Systemstate Dump Oracle
  • For Perl DBI installation and testing program PHP/MYSQL/Wordpress
  • Identical Dblink Issue… Oracle
  • Proc Compilation Oracle
  • DBMS_UTILITY.ANALYZE_SCHEMA Oracle
  • Jai Shree Ram Oracle
  • How to know current SID Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme