Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

is it possible to simulate the DBMS_CRYPTO.encrypt_aes128 in PERL?

580165Mar 22 2010 — edited Mar 22 2010
Good morning,

We are trying to replicate some of the logic we have in our database at the application layer to try and free up some more resources in our primary DB instance. The process in question uses the DBMS_CRYPTO.encrypt_aes128 function to encrypt a key and then store the encrypted data in a table. We'd like to do this encryption at the application layer instead. The app layer is currently a PERL environment.

I'm trying to write a process using Crypt::CBC with a cipher object constructed from Crypt::Rijndael, but I still can't get my encrypted data to match when i encrypt at the database level vs the app layer level.

My db code looks something like this:

FUNCTION encryptThis( p_txt IN VARCHAR )
RETURN VARCHAR2
AS
v_cipher NUMBER
:= DBMS_CRYPTO.encrypt_aes128
+ DBMS_CRYPTO.chain_cbc
+ DBMS_CRYPTO.pad_pkcs5;
BEGIN
RETURN UTL_I18N.raw_to_char
( DBMS_CRYPTO.encrypt
( UTL_I18N.string_to_raw( p_txt,
'AL32UTF8'
),
v_cipher,
UTL_I18N.string_to_raw
( '16CharactersText',
'AL32UTF8'
)
),
'AL32UTF8'
);
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END encryptThis;


Has anyone ever had to do anything similar ?

My db instance is Oracle 10.2.0.4 running on Solaris.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 19 2010
Added on Mar 22 2010
1 comment
543 views