사용자 도구

사이트 도구


oracle:sha256

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
oracle:sha256 [2018/10/31 02:56] – [ORACLE SHA256] taekguoracle:sha256 [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 ===== ORACLE SHA256 ===== ===== ORACLE SHA256 =====
  
-==== HMAC_SHA256 ====+ 
 +==== SHA256 PACKAGE ==== 
 +GitHub : CruiserX/sha256_plsql 
 +  * 간단한 사용법
 <code sql> <code sql>
-create or replace Function hmac_sha256 +select b.password as pwda.emp_nof_shaencryptor(substr(CTZ_NO,7)) as f_java, 
-  ( +  sha256.encrypt(substr(ctz_no,7)) as f_pkg 
-    ptext Varchar2, +  from vi_frm_phm_emp a 
-    pkey  Varchar2 +  join frm_user b 
-  ) Return Varchar2 +  on a.emp_no = b.login_id
- Is +
-    -- pad const +
-    c_opad      Raw(1) := '5c'; +
-    c_ipad      Raw(1) := '36'; +
-    c_kpad      Raw(1) := '00'; +
- +
-    --SHA256 block size 512 bit +
-    c_blocksize Integer := 64; +
- +
-    --local var, length equals to blocksize +
-    l_opad        Raw(64); +
-    l_ipad        Raw(64); +
-    l_key         Raw(64); +
-  Begin +
- +
-    l_opad := utl_raw.copies(c_opadc_blocksize); +
-    l_ipad := utl_raw.copies(c_ipadc_blocksize); +
- +
-    If utl_raw.length(utl_raw.cast_to_raw(pkey)) > c_blocksize Then +
-      l_key := utl_raw.cast_to_raw(sha256.encrypt(pkey)); +
-    Else +
-      l_key := utl_raw.cast_to_raw(pkey); +
-    End If; +
- +
-    l_key := l_key || +
-             utl_raw.copies(c_kpadc_blocksize - utl_raw.length(l_key)); +
- +
-    Return sha256.encrypt_raw(utl_raw.bit_xor(l_key, l_opad) || +
-                              sha256.encrypt_raw(utl_raw.bit_xor(l_key, l_ipad) || utl_raw.cast_to_raw(ptext)) +
-                              ); +
- +
-  End;+
 </code> </code>
-==== SHA256 PACKAGE ====+=== PL/SQL Source ===
 <code sql> <code sql>
 CREATE OR REPLACE PACKAGE SHA256 IS CREATE OR REPLACE PACKAGE SHA256 IS
줄 772: 줄 743:
 END SHA256; END SHA256;
 / /
 +</code>
 +
 +==== HMAC_SHA256 ====
 +<code sql>
 +create or replace Function hmac_sha256
 +  (
 +    ptext Varchar2,
 +    pkey  Varchar2
 +  ) Return Varchar2
 + Is
 +    -- pad const
 +    c_opad      Raw(1) := '5c';
 +    c_ipad      Raw(1) := '36';
 +    c_kpad      Raw(1) := '00';
 +
 +    --SHA256 block size 512 bit
 +    c_blocksize Integer := 64;
 +
 +    --local var, length equals to blocksize
 +    l_opad        Raw(64);
 +    l_ipad        Raw(64);
 +    l_key         Raw(64);
 +  Begin
 +
 +    l_opad := utl_raw.copies(c_opad, c_blocksize);
 +    l_ipad := utl_raw.copies(c_ipad, c_blocksize);
 +
 +    If utl_raw.length(utl_raw.cast_to_raw(pkey)) > c_blocksize Then
 +      l_key := utl_raw.cast_to_raw(sha256.encrypt(pkey));
 +    Else
 +      l_key := utl_raw.cast_to_raw(pkey);
 +    End If;
 +
 +    l_key := l_key ||
 +             utl_raw.copies(c_kpad, c_blocksize - utl_raw.length(l_key));
 +
 +    Return sha256.encrypt_raw(utl_raw.bit_xor(l_key, l_opad) ||
 +                              sha256.encrypt_raw(utl_raw.bit_xor(l_key, l_ipad) || utl_raw.cast_to_raw(ptext))
 +                              );
 +
 +  End;
 </code> </code>
oracle/sha256.1540954588.txt.gz · 마지막으로 수정됨: 2025/04/15 10:05 (바깥 편집)