Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Storing/retrieving DES3 data w/Perl

RE: Storing/retrieving DES3 data w/Perl

From: Jesse, Rich <Rich.Jesse_at_qtiworld.com>
Date: Tue, 20 Aug 2002 11:13:22 -0800
Message-ID: <F001.004BA3C6.20020820111322@fatcity.com>


A-ha! I knew it was casting that was getting me. On the way back from raw to varchar2 the Oracle builtin will do NLS_LANG conversion.

THANKS, Jared! Does this mean I need to buy two of your books now? ;)

Rich Jesse                           System/Database Administrator
Rich.Jesse_at_qtiworld.com              Quad/Tech International, Sussex, WI USA

> -----Original Message-----
> From: Jared.Still_at_radisys.com [mailto:Jared.Still_at_radisys.com]
> Sent: Tuesday, August 20, 2002 12:14 PM
> To: ORACLE-L_at_fatcity.com
> Cc: Jesse, Rich
> Subject: Re: Storing/retrieving DES3 data w/Perl
>
>
> Well, here's one way to do it.
>
> This converts the data to hex before storing in Oracle.
>
> Jared
>
> #!/usr/bin/perl
>
> use DBI qw(:sql_types);
> use Crypt::TripleDES;
>
> my ($DBname, $Uname, $Pword ) = ('MYDB','MYUSER','MYPASS');
> my $DESpass = "abcdefgh";
>
> $dbh = DBI->connect(
> "dbi:Oracle:dv01","scott","tiger",
> {
> RaiseError => 1,
> AutoCommit => 0
> }
> );
>
> my $DES3 = new Crypt::TripleDES;
> my $Cryptpass = $DES3->encrypt3 ( $Pword, $DESpass );
> my $hexPassword = unpack("H*",$Cryptpass);
>
> print "Clear : $Pword\n";
> print "Decrypt: ", $DES3->decrypt3($Cryptpass, $DESpass),"\n";
> print "Hex : $hexPassword\n";
>
> $dbh->do('truncate table valid_connection');
>
> $sth = $dbh->prepare(qq(
> INSERT INTO valid_connection(
> db_alias, db_username, db_password,
> clear_password
> )
> VALUES(?,?,?,?)
> )
> );
>
> $sth->execute($DBname, $Uname, $hexPassword, $Pword);
>
> $sth = $dbh->prepare(qq
> {
> SELECT
> db_alias, db_username, db_password,
> clear_password
> FROM valid_connection
> }
> );
>
> $sth->execute;
>
> while ( my $hr = $sth->fetchrow_hashref)
> {
> my $clearPassword = $DES3->decrypt3(pack("H*",
> $hr->{DB_PASSWORD}), $DESpass);
> print "$hr->{DB_ALIAS} $hr->{DB_USERNAME}
> $clearPassword\n";
> }
>
> $dbh->disconnect;

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jesse, Rich
  INET: Rich.Jesse_at_qtiworld.com

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).
Received on Tue Aug 20 2002 - 14:13:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US