오라클 암호화 툴킷 사용하기
1. sys 계정으로 로그인
su - oracle
sqlplus /nolog
conn sys/manager as sysdba
sqlplus /nolog
conn sys/manager as sysdba
2. dbms_obfuscation_toolkit 툴킷 설치
@$ORACLE_HOME/rdbms/admin/dbmsobtk.sql
@$ORACLE_HOME/rdbms/admin/prvtobtk.plb
@$ORACLE_HOME/rdbms/admin/prvtobtk.plb
grant execute on dbms_obfuscation_toolkit to public;
3. 패키지 생성 (오라클 일반 유저 계정으로)
CREATE OR REPLACE PACKAGE CryptIT AS
FUNCTION encrypt( Str VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2;
FUNCTION decrypt( xCrypt VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2;
END CryptIT;
/
FUNCTION encrypt( Str VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2;
FUNCTION decrypt( xCrypt VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2;
END CryptIT;
/
CREATE OR REPLACE PACKAGE BODY CryptIT AS
crypted_string VARCHAR2(2000);
FUNCTION encrypt( Str VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2 AS
pieces_of_eight INTEGER := ((FLOOR(LENGTH(Str)/8 + .9)) * 8);
hash VARCHAR2 ) RETURN VARCHAR2 AS
pieces_of_eight INTEGER := ((FLOOR(LENGTH(Str)/8 + .9)) * 8);
BEGIN
dbms_obfuscation_toolkit.DESEncrypt(
input_string => RPAD( Str, pieces_of_eight ),
key_string => RPAD(hash,8,'#'),
encrypted_string => crypted_string );
RETURN crypted_string;
END;
input_string => RPAD( Str, pieces_of_eight ),
key_string => RPAD(hash,8,'#'),
encrypted_string => crypted_string );
RETURN crypted_string;
END;
FUNCTION decrypt( xCrypt VARCHAR2,
hash VARCHAR2 ) RETURN VARCHAR2 AS
BEGIN
dbms_obfuscation_toolkit.DESDecrypt(
input_string => xCrypt,
key_string => RPAD(hash,8,'#'),
decrypted_string => crypted_string );
RETURN trim(crypted_string);
END;
END CryptIT;
/
hash VARCHAR2 ) RETURN VARCHAR2 AS
BEGIN
dbms_obfuscation_toolkit.DESDecrypt(
input_string => xCrypt,
key_string => RPAD(hash,8,'#'),
decrypted_string => crypted_string );
RETURN trim(crypted_string);
END;
END CryptIT;
/
댓글 없음:
댓글 쓰기