Home » SQL & PL/SQL » SQL & PL/SQL » CRYPT DATA IN TABLES
CRYPT DATA IN TABLES [message #37054] Sun, 13 January 2002 05:47 Go to next message
Juffi
Messages: 5
Registered: January 2002
Junior Member
i have a Oracle 7.3.4.0.0 , how can i crypt a data in tables with these ver.
Re: CRYPT DATA IN TABLES [message #37058 is a reply to message #37054] Mon, 14 January 2002 00:29 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
Hi,

This functionality available in oracle 8.1.6 through dbms_util.get_hash_value but not in 7.3.4.
You can simulate that functionality in 7.3.

Try translate function to crypt the data.

cheers
pratap
Re: CRYPT DATA IN TABLES [message #37060 is a reply to message #37054] Mon, 14 January 2002 08:05 Go to previous messageGo to next message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
http://www.oracle.com/oramag/code/index.html?cod11226.html

create or replace FUNCTION Xorbin(c1 CHAR,c2 CHAR) RETURN CHAR IS
  loop1   NUMBER;
  loop11  NUMBER;
  r1     VARCHAR2(8);
  r2     VARCHAR2(8);
  r3     NUMBER;
  result VARCHAR2(40);
  divis  NUMBER;
BEGIN
  result := '';
  FOR loop1 IN 1..LENGTH(c1) LOOP
    r1 := Convbin(SUBSTR(c1,loop1,1));
    r2 := Convbin(SUBSTR(c2,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);
END;
/

create or replace FUNCTION Convbin(c1 CHAR) RETURN CHAR IS
  loop1  NUMBER;
  value NUMBER;
  divis NUMBER;
  r1    VARCHAR2(30);
-- encryption encrypt crypt unencrypt in Oracle

BEGIN
  r1 := '';
  value := ASCII(c1);
  divis := 128;
  FOR loop1 IN 0..7 LOOP
    IF TRUNC(value/divis) = 1 THEN
      r1 := r1 || '1';
    ELSE
      r1 := r1 || '0';
    END IF;
    value := value MOD divis;
    divis := divis / 2;
  END LOOP;
  RETURN r1;
END;
/

-- SET serveroutput ON
-- DECLARE
--   result  VARCHAR2(30);
--   mask    VARCHAR2(30);
-- BEGIN
--   mask    := 'abc'; /* Must be greater or equal to the value that
--                        will be "Crypted" */
--
--   result := XORBIN('ABD',mask);  /* "Crypt" */
--   dbms_output.put_line(result);
--
--   result := XORBIN(result,mask); /* "Unencrypt" */
--   dbms_output.put_line(result);
--
-- END;
-- /

Re: CRYPT DATA IN TABLES [message #37063 is a reply to message #37054] Mon, 14 January 2002 09:52 Go to previous message
Juffi
Messages: 5
Registered: January 2002
Junior Member
Andrew big thx its working :)
Previous Topic: How to specify IN and OUT in PL/SQL
Next Topic: X$ tables
Goto Forum:
  


Current Time: Fri Feb 21 01:07:35 CST 2020