Re: dbms_crypto_toolkit error

From: S Schaber <sschaber_at_yahoo.com>
Date: 1999/09/09
Message-ID: <37D88B3C.F441A7E4_at_yahoo.com>#1/1


I'm not trying to generate random numbers. I want to encrypt strings using either encrypt or hash procedure in dbms_crypto_toolkit. Do you have an example that uses these procedures?

Thanks,
Steve.

Yass Khogaly wrote:

> Please follow those steps "TO GENERATE RANDOM NUMBERS"
>
> 1. Initialize random number generator with seed. The
> seed should be at least 5 digits according to the
> package comments to ensure randomness.
>
> Example:
>
> SQL> exec dbms_random.initialize (12345);
>
> PL/SQL procedure successfully completed.
>
> 2. Generate random number.
>
> Example 1:
>
> SQL> set serveroutput on
>
> SQL> declare
> 2 random_number binary_integer;
> 3 begin
> 4 random_number := dbms_random.random;
> 5 dbms_output.put_line(to_char(random_number));
> 6 end;
> 7 /
>
> 2116177396
>
> PL/SQL procedure successfully completed.
>
> Example 2: (from Oracle Cryptographic Toolkit
> Programmer's Guide Rel 2.0.4)
>
> DECLARE
> i BINARY_INTEGER;
> BEGIN
> dbms_random.initialize(19254);
> i := dbms_random.random;
> INSERT INTO some_table VALUES(i);
> dbms_random.terminate;
> END;
>
> 3. Terminate the random number generator to release memory.
>
> Example:
>
> SQL> exec dbms_random.terminate;
>
> PL/SQL procedure successfully completed.
>
> 4. Change the random number generator seed after initial
> initialization.
>
> Example:
>
> SQL> exec dbms_random.seed (12346);
>
> PL/SQL procedure successfully completed.
>
> 5. Warnings
>
> If dbms_random.terminate has been executed after
> dbms_random.random was successful, then subsequent
> executions of dbms_random.random may return neither
> a result or an error. If dbms_random.random is run
> before executing dbms_random.initialize then an
> exception will be raise and "ORA-06510: PL/SQL:
> unhandled user-defined exception results if the
> exception is not handled in the pl/sql block. It is
> not currently possible to use the return value of the
> random function directly in a SQL statement.
>
> Example:
>
> SQL> exec dbms_random.initialize (12345);
>
> PL/SQL procedure successfully completed.
>
> SQL> insert into x values(dbms_random.random);
> insert into x values(dbms_random.random)
> *
> ERROR at line 1:
> ORA-06571: Function RANDOM does not guarantee
> not to update the database.
>
> Regards
>
> "The Views expressed here are my own and not necessarily those of Oracle
> Corporation"
>
> S Schaber <sschaber_at_yahoo.com> wrote in message
> news:37D6A602.BD6E7A9_at_yahoo.com...
> >
> > Env: Oracle 8.0.5.1 on solaris
> >
> > I'm trying to use dbms_crypto_toolkit package
> > to encrypt strings. It gives this error:
> >
> > declare
> > *
> > ERROR at line 1:
> > ORA-06550: line 10, column 11:
> > PLS-00307: too many declarations of 'ENCRYPT' match this call
> > ORA-06550: line 10, column 3:
> > PL/SQL: Statement ignored
> >
> > My code is:
> >
> > declare
> > ps dbms_crypto_toolkit.Persona := null;
> > i number;
> > str1 varchar2(1000);
> > begin
> > dbms_crypto_toolkit.Initialize;
> > dbms_crypto_toolkit.CreatePersona(dbms_crypto_toolkit.MD5,
> > null, 'aaa', 'aaa', 'aaa', ps);
> > str1 := 'aaa';
> > str1 := dbms_crypto_toolkit.Encrypt(ps, str1);
> > dbms_crypto_toolkit.Terminate;
> >
> > end;
> > /
> >
> >
Received on Thu Sep 09 1999 - 00:00:00 CEST

Original text of this message