简体   繁体   中英

Is there any function or package to generate md5crypt string in Oracle?

We'd like to encrypt user password in exported file from Oracle, password should be md5crypt string, like $1$salt$hash.

--PowerShell Git function example:
Get-Md5Crypt('sachiko')
$1$gfJ1cxju47$hLcMO7LZyA2Z74yTP.TmW1

I'm just wondering "DBMS_CRYPTO" function can generate MD5 with salt. So far, can't find any good examples though. If there is no appropriate function or package provided by Oracle, we can apply any alternative way.

Any advice would be highly appreciated. Thank you.

Here is an oracle function that will return an encrypted sha512 output. As mentioned above, if you plan on saving the value it should be in a column defined as RAW ie hash_val RAW(700). as DBMS_CRYPTO.HASH returns a RAW datatype.


CREATE or REPLACE FUNCTION HASH_SHA512 (
    psINPUT IN VARCHAR2
    ) RETURN VARCHAR2 AS
    rHash RAW (512);
    BEGIN
    rHash := DBMS_CRYPTO.HASH (TO_CLOB (psINPUT), 
dbms_crypto.HASH_SH512);
    RETURN (LOWER (RAWTOHEX (rHash)));
    END HASH_SHA512;
/


SELECT HASH_SHA512('testsha512 output') from dual

7a1b50a71560fb87ce90013b9845a36edf26964655930365aec44ea1f1a9f45763f082b148b8b99dc11b71ea5336e3a93f6382ced2a914434352c2ddb48ad69e

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM