Home » SQL & PL/SQL » SQL & PL/SQL » DBMS_CRYPTO (11g database)
DBMS_CRYPTO [message #636208] Mon, 20 April 2015 01:35 Go to next message
vippysharma
Messages: 73
Registered: May 2013
Location: www
Member
create table login_details
(
  EMP_ID      VARCHAR2(10),
  USER_NAME   VARCHAR2(50),
  ID_PASSWORD NUMBER
);


create or replace procedure P_PASSWORD_ENCRYPT(par_id       in VARCHAR2,
                                               par_username in varchar2,
                                               par_password in number) is
  l_hash raw(2000);
begin
  l_hash := dbms_crypto.hash(utl_i18n.string_to_raw(par_password,
                                                    'AL32UTF8'),
                             dbms_crypto.hash_sh1);
  insert into login_details
    (EMP_ID, USER_NAME, ID_PASSWORD)
  values
    (par_id, par_username, l_hash);

end P_PASSWORD_ENCRYPT;


BEGIN
  P_PASS_ENCRYPT('IT_001','SCOTT',123456);
  END;



* My procedure shown error as 'inconsistent datatype' which is quite obvious because raw datatype can't be stored in number field.But i want my encrypted value be in number datatype, which is same as my password field have in table.
Is that possible ?
Re: DBMS_CRYPTO [message #636209 is a reply to message #636208] Mon, 20 April 2015 01:43 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
SHA1 does not return ASCII characters. So you have to use raw.
Re: DBMS_CRYPTO [message #636213 is a reply to message #636208] Mon, 20 April 2015 02:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
But i want my encrypted value be in number datatype, which is same as my password field have in table.
Is that possible ?


Change the datatype of your password field to RAW.

Re: DBMS_CRYPTO [message #636216 is a reply to message #636208] Mon, 20 April 2015 04:16 Go to previous messageGo to next message
vippysharma
Messages: 73
Registered: May 2013
Location: www
Member
@Michal
Quote:
But i want my encrypted value be in number data type, which is same as my password field have in table.Is that possible ?

Means if i entered password as 123456 then after encryption result should be shown as 654667453846515156421654 (Encrypted in number only).

Quote:
Change the data type of your password field to RAW.

Its my project requirement that i only have to use number data type in password and also restrict its actual value and show some other encrypted value but in number only.
Anyway Thanks for your help Smile

-------------------------------------------------------------------------
@john
Quote:
SHA1 does not return ASCII characters.So you have to use raw.
.

I got that. Thanks Smile Confused

Re: DBMS_CRYPTO [message #636218 is a reply to message #636216] Mon, 20 April 2015 04:31 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Actually, I mean the same thing than John.
You have one thing you can't change: the return value of SHA1 function.
You have things you can change: your encrypted column data type and requirements.
What is the business reason for an encrypted column to be a NUMBER and nothing else?
None I can see, so this requirement can be changed without any business drawback.

[Updated on: Mon, 20 April 2015 06:54]

Report message to a moderator

Re: DBMS_CRYPTO [message #636222 is a reply to message #636218] Mon, 20 April 2015 06:32 Go to previous message
vippysharma
Messages: 73
Registered: May 2013
Location: www
Member
Michel Cadot wrote on Mon, 20 April 2015 14:31
What is the business reason for an encrypted column to be a NUMBER and nothing else?
None I can see, so this requirement can be changed without any business drawback.


You are right,its senseless or any amendment doesn't make any drawback. But Requirement is what user's choice either useless or whatever.

Previous Topic: Same Query taking significantly different time on different days
Next Topic: Date functions
Goto Forum:
  


Current Time: Thu Apr 25 21:58:48 CDT 2024