I would like to know how I do to encrypt a password and then be able to decrypt. How can I do this?! Is there any Oracle function or would you have to create some script for this?!
Cryptography
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
It depends on the case ... You said you want to encrypt a password and then decrypt. In this case, the best way is to use a hash, that is, you generate a unique key of your password that is impossible to decrypt. Hence, you just compare this key with the key that the user typed ... (In this way, not even a DBA or the people who created the system can see the password that the user registered).
Here is an example, taken from AskTom: http://asktom.oracle.com/pls/ask/f?p=49 ... 5412348059
Now, if you want to encrypt And decrypt information (for example, the employee salaries column). Then you can use an Oracle DBMS. Obfuscation Toolkit. This example was also taken from the Asktom ... http://asktom.oracle.com/pls/ask/f?p=49 ... 1026226790
Here is an example, taken from AskTom: http://asktom.oracle.com/pls/ask/f?p=49 ... 5412348059
declare
function digest( p_username in varchar2, p_password in varchar2 ) return varchar2
is
begin
return ltrim( to_char( dbms_utility.get_hash_value(
upper(p_username)||'/'||upper(p_password),
1000000000,
power(2,30) ),
rpad( 'X',29,'X')||'X' ) );
end digest;
begin
for x in ( select username from all_users where rownum < 20 )
loop
dbms_output.put_line( 'User: ' || rpad( x.username , 30 ) ||
' digest: ' || digest( x.username, 'TIGER' )
);
end loop;
end;
/
User: SYS digest: 6869FA1A
User: SYSTEM digest: 79F08AFC
User: OUTLN digest: 5ABFB255
User: DBSNMP digest: 43415F6B
User: TRACESVR digest: 49CF26F6
User: CTXSYS digest: 4910C297
User: OEM digest: 69463BC2
User: ORDSYS digest: 6F048B2B
User: ORDPLUGINS digest: 6547459C
User: MDSYS digest: 43C0B367
User: AURORA$ORB$UNAUTHENTICATED digest: 5073BBFC
User: WEB$CDEJESUS digest: 6FB5CDB6
User: SCOTT digest: 4307767C
User: WEB$SMAYFIEL digest: 71ED5065
User: UTILS digest: 5B7912B7
User: OAS_PUBLIC digest: 502BAE3A
User: WEBDB digest: 5A7AC149
User: WEB$RDRISCOL digest: 3E72D3F6
User: WEB$KWARREN digest: 7123F5A1
PL/SQL procedure successfully completed.
ops$tkyte@DEV816> variable x varchar2(25)
ops$tkyte@DEV816>
ops$tkyte@DEV816> exec :x := 'How Now Brown Cow';
PL/SQL procedure successfully completed.
ops$tkyte@DEV816>
ops$tkyte@DEV816> declare
2 l_data varchar2(255);
3 begin
4 l_data := rpad( :x, (trunc(length(:x)/8)+1)*8, chr(0) );
5
6 dbms_obfuscation_toolkit.DESEncrypt
7 ( input_string => l_data,
8 key_string => 'MagicKey',
9 encrypted_string=> :x );
10 end;
11 /
PL/SQL procedure successfully completed.
ops$tkyte@DEV816>
ops$tkyte@DEV816> print x
X
-------------------------
Òr
-
- Rank: Estagiário Pleno
- Posts: 5
- Joined: Thu, 06 Oct 2005 4:08 pm
- Location: Pelotas - RS
---
Rogerio Albandes
PipeGrep Conectividade Ip - www.pipegrep.com.br
Fone: 53 3222-3366 Cel: 53 8401-4872
Rogerio Albandes
PipeGrep Conectividade Ip - www.pipegrep.com.br
Fone: 53 3222-3366 Cel: 53 8401-4872
I come from MySQL, where you have the Crypt () function and MD5 ().
I just want to keep the users' passwords from a written system in Delphi, but as I have a written and php part, I want this encryption to be done by the bank
I just want to keep the users' passwords from a written system in Delphi, but as I have a written and php part, I want this encryption to be done by the bank
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Unfortunately in Oracle this function does not exist. You will have to create one of its own. (This DBMS used in the second example above is the solution for your problem: dbms_obfuscation_toolkit .
She is installed along with Oracle. doubt, send us! But basically what you have to do is create a function with the routines used in this example above ... (encrypted and decryption) ...
: - O
She is installed along with Oracle. doubt, send us! But basically what you have to do is create a function with the routines used in this example above ... (encrypted and decryption) ...
: - O
-
- Rank: Estagiário Júnior
- Posts: 1
- Joined: Thu, 13 Oct 2005 12:18 pm
- Location: Rio de Janeiro
This encryption package accepts the maximum size of text to be encrypted. I did a test here with a text and with a key attmante and the size of the size or size of the key or text would be allowed.
has any reference on optimal key and text size.
Another thing, when we give a wrap on the code which is in quotation marks (text) it is not wrapped. Is it visible, any tips?
has any reference on optimal key and text size.
Another thing, when we give a wrap on the code which is in quotation marks (text) it is not wrapped. Is it visible, any tips?
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Wow, I'm not having time to test here the maximum size. I only know that it should be multiple of 8 characters. (See example, has a RPDAD that fills with CHR (0) to string.
Good afternoon guys, I'm new to Oracle, and I did not quite understand the encryption part, I know there are packages in Oracle that can be used to do this operation. But how do I create a function using dbms_obfuscation_toolkit.desencrypt? I would have to use a function to encrypt and another to decrypt is this?, In the case dbms_obfuscation_toolkit.desdecrypt?
Someone could give me a simple sample function of encryption function, because I did not understand how to use this dbms_obfuscation_toolkit
would be something more or less like this?
Thanks from now on /
Someone could give me a simple sample function of encryption function, because I did not understand how to use this dbms_obfuscation_toolkit
would be something more or less like this?
CREATE OR REPLACE FUNCTION fn_criptografia
(
p_login IN RAW
,p_senha IN RAW
,p_senha_encriptada OUT RAW
) RETURN RAW AS
v_result RAW(128);
BEGIN
DBMS_OBFUSCATION_TOOLKIT.DESEncrypt (p_login, p_senha, p_senha_encriptada);
RETURN v_result;
END;
Thanks from now on /
I would only like an example well Simple, and then I create my own keymaikew wrote: Good afternoon guys, I'm new to Oracle, and I did not quite understand the encryption part, I know there are packages in Oracle that can be used to do this operation. But how do I create a function using dbms_obfuscation_toolkit.desencrypt? I would have to use a function to encrypt and another to decrypt is this?, In the case dbms_obfuscation_toolkit.desdecrypt?
Someone could give me a simple example of encryption function, because I did not understand how to use this dbms_obfuscation_toolkit
would be something more or less like this?CREATE OR REPLACE FUNCTION fn_criptografia ( p_login IN RAW ,p_senha IN RAW ,p_senha_encriptada OUT RAW ) RETURN RAW AS v_result RAW(128); BEGIN DBMS_OBFUSCATION_TOOLKIT.DESEncrypt (p_login, p_senha, p_senha_encriptada); RETURN v_result; END;
Thanks from now on /
-
- Rank: Programador Sênior
- Posts: 52
- Joined: Sat, 29 Sep 2007 12:59 am
- Location: Araraquara-SP
- Contact:
Ricardo Neves
Analista e Instrutor Oracle Developer
Java Developer (JPA/JSF/Hibernate/WebServices/EJB)
Analista e Instrutor Oracle Developer
Java Developer (JPA/JSF/Hibernate/WebServices/EJB)
You can create a function to use MD5 in the oracle
create or replace function fnc_md5 (p_valor varchar) return varchar2 is
v_entrada varchar2(2000) := p_valor;
hexkey varchar2(32) := null;
begin
hexkey := rawtohex(dbms_obfuscation_toolkit.md5(input => utl_raw.cast_to_raw(v_entrada)));
return nvl(hexkey,'');
end;
/
ricards wrote: You can create a function to use MD5 in this form in Oracle/ Quote]create or replace function fnc_md5 (p_valor varchar) return varchar2 is v_entrada varchar2(2000) := p_valor; hexkey varchar2(32) := null; begin hexkey := rawtohex(dbms_obfuscation_toolkit.md5(input => utl_raw.cast_to_raw(v_entrada))); return nvl(hexkey,''); end; /
Thanks. I already knew this MD5 function, but I need to uncropped the password, I need the original value of it, because I will not compare the hash value with another hash generated from the password entered, I will need to use the original password in another location só wanted an example of how to build a key, as simple as possible to use dbms_obfuscation_toolkit.desencrypt () and dbms_obfuscation_toolkit.desdecrypt () if possible.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 5 guests