Recently, I was working on upgrading the company's internal system. The original system does not require encryption of passwords. Now I need MD5 encryption.
Oracle Database Password MD5 encryption, Oracle provides the MD5 encryption function.
However, if the password is empty, an error is reported. After searching for the password for a long time, I did not find a solution. Finally, I asked
Solve the problem.
Fn_md5 function:
Create or replace function fn_md5 (input_string in varchar2)
Return varchar2
Is
Raw_input raw (128)
: = Utl_raw.cast_to_raw (input_string );
Decrypted_raw raw (2048 );
Error_in_input_buffer_length exception;
Begin
Dbms_obfuscation_toolkit.md5 (input => raw_input,
Checksum => decrypted_raw
);
Return upper (rawtohex (decrypted_raw ));
End;
Encrypted SQL statement:
Update uum_user R set R. user_passwd = decode (R. user_passwd, '', 'd41d8cd98f00b204e9800998ecf8427e ', fn_md5 (R. user_passwd ));
Decode (A, B, C, D, E, F ......) Function. If the value of A is equal to B, the function returns C. If the value of A is equal to D, E… is returned .......