?
Solved

Encrypt and Decrypt with DES3Encrypt Oracle

Posted on 2003-11-05
3
Medium Priority
?
1,768 Views
Last Modified: 2007-12-19
Hi
I have a function

create or replace function endecrypt_fnc(
  inValue  varchar2,  --Value to en/decrypt
  inMethod varchar2  --'E' Encrypt; 'D' Decrypt
) return varchar2
is
  loResult         varchar2(4096) ;
  loKey            VARCHAR2(24) := 'QWERTYUIASDFGHJKZXCVBNM,';
  lovalue          VARCHAR2(4096) ;
  loMethod         varchar2(1);
  error_in_input_buffer_length EXCEPTION;
  PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232);
  INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) := '*** DES INPUT BUFFER NOT A MULTIPLE OF 8 BYTES ***';
  i number;
BEGIN
  if inValue is null then
    return null;
  end if;
  loValue := inValue;
  loMethod := upper(inMethod);
  if loMethod='E' THEN
    loResult :=  dbms_obfuscation_toolkit.DES3Encrypt(
       input_string => loValue,
       key_string => loKey,
       which => 1);
  end if;
  if loMethod='D' THEN
    loResult :=  dbms_obfuscation_toolkit.DES3Decrypt(
       input_string => loValue,
       key_string => loKey,
       which => 1);
  end if;
  return loResult;

EXCEPTION
WHEN error_in_input_buffer_length THEN
  dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG);

end endecrypt_fnc;

I tested with some values below:
  endecrypt_fnc(endecrypt_fnc('12345678','E'),'D') it's ok
but when i tested
  endecrypt_fnc(endecrypt_fnc('913122875       ','E'),'D') the return value does not match.

---length('913122875       ')=16----

Let me know what something wrong, pls?
Thanks
HieuTD
0
Comment
Question by:hieutd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 1000 total points
ID: 9688046
try to use a longer key 32 bytes.
---> loKey            VARCHAR2(24) := 'QWERTYUIASDFGHJKZXCVBNM,';
loKey            VARCHAR2(24) := 'IDLSFDKLQWERTYUIASDFGHJKZXCVBNM,';
0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question