강좌
클라우드/리눅스에 관한 강좌입니다.
데이터베이스 분류

오라클에서 데이터의 암호화/복호화

작성자 정보

  • 웹관리자 작성
  • 작성일

컨텐츠 정보

본문

오라클에서 데이터의 암호화/복호화

 

t.gif
t.gif
오라클 8.1.6부터 DBMS_OBFUSCATION_TOOLKIT라는 PL/SQL패키지가 제공된다.
이 패키지는 암호화/복호화를 수행하는 2개의 DES프로시저를 가지고 있다.
주의할 점은 8byte의 배수로 이루어져만 암호화가 가능하다는 지랄같은(--;) 제약이 있다.


예를 들어 설명드리겠습니다.

SQL> connect kang/xxxxxx
연결되었습니다.

SQL> !cat test.sql
DECLARE
    input_string     VARCHAR2(8) := 'mustbe8s';
    raw_input        RAW(128)    := UTL_RAW.CAST_TO_RAW(input_string);
    key_string       VARCHAR2(8) := 'myunggyu';
    raw_key          RAW(128)    := UTL_RAW.CAST_TO_RAW(key_string);
    encrypted_raw    RAW(2048);
    encrypted_string VARCHAR2(2048);
    decrypted_raw    RAW(2048);
    decrypted_string VARCHAR2(2048);

BEGIN
    
    dbms_output.put_line('> input string : ' || input_string);
    
    dbms_obfuscation_toolkit.DESEncrypt(input_string => input_string,
                                        key_string => key_string,
                                        encrypted_string => encrypted_string );
    
    dbms_output.put_line('> encrypted hex value : ' ||
                            rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_string)));
    
    dbms_obfuscation_toolkit.DESDecrypt(input_string => encrypted_string,
                                        key_string => key_string,
                                        decrypted_string => decrypted_string );
    
    dbms_output.put_line('> decrypted string output : ' ||
                            decrypted_string);
    
    if input_string = decrypted_string THEN
        dbms_output.put_line('> String DES Encyption and Decryption successful');
    END if;
END;
/

SQL> set serveroutput on
SQL> @test
> input string : mustbe8s
> encrypted hex value : BBD15581726E4A72
> decrypted string output : mustbe8s
> String DES Encyption and Decryption successful

PL/SQL procedure successfully completed.

SQL>

This article comes from dbakorea.pe.kr (Leave this line as is)

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,037 명
  • 현재 강좌수 :  35,810 개
  • 현재 접속자 :  109 명