- Goal
USERのパスワード設定時、また認証時に呼び出すハッシュ化関数を作成する - Source : MD5のハッシュ化 (9i)
apex.oracle.com 上ではDBMS_CRYPTOが使えないらしいので、ここではMD5を使用
(あくまでテスト環境だからか…) - Source : SHA1のハッシュ化(10g / 11g)
- Source : SHA2のハッシュ化
(To be updated.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function "MD5_HASH" | |
(g_user_name in VARCHAR2, | |
g_password in VARCHAR2) | |
return VARCHAR2 | |
is | |
l_password VARCHAR2 (4000); | |
l_salt VARCHAR2 (4000) := 'SALTSALTSALTSALTSALT'; -- Need to change your original. | |
BEGIN | |
l_password := | |
UTL_RAW.cast_to_raw (DBMS_OBFUSCATION_TOOLKIT.md5 (input_string => g_password | |
|| SUBSTR ( l_salt, 13, 16) | |
|| upper(g_user_name) | |
|| SUBSTR ( l_salt, 4, 10))); | |
RETURN l_password; | |
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE function SHA1_HASH(p_username in VARCHAR2,p_password in VARCHAR2) | |
return VARCHAR2 | |
is | |
l_password VARCHAR2 (4000); | |
l_salt VARCHAR2 (4000) := 'SALTSALTSALTSALTSALTSALT'; -- change with your salt. | |
BEGIN | |
l_password := | |
DBMS_CRYPTO.HASH(src => UTL_I18N.STRING_TO_RAW(p_password | |
|| SUBSTR ( l_salt, 10, 13) | |
|| upper(p_username) | |
|| SUBSTR( l_salt, 4, 10),'AL32UTF8'), | |
typ => DBMS_CRYPTO.HASH_SH1 | |
); | |
RETURN l_password; | |
END; |
0 件のコメント:
コメントを投稿