당신은 PL/SQL에서 자바를 호출 할 수 있습니다. 너무 복잡하지는 않지만 정확한 프로세스를 찾기 위해 조사를해야합니다. 당신은 암호화 알고리즘에 제한되지 않는 경우 , 당신은 예를 들어, 다른 사용할 수 있습니다
CREATE OR REPLACE PACKAGE Cryptit AS
FUNCTION encrypt(Str VARCHAR2) RETURN RAW;
FUNCTION decrypt(xCrypt VARCHAR2) RETURN VARCHAR2;
FUNCTION encrypt_with_key(Str VARCHAR2, key VARCHAR2) RETURN RAW;
FUNCTION decrypt_with_key(xCrypt VARCHAR2, key VARCHAR2) RETURN VARCHAR2;
END Cryptit;
/
CREATE OR REPLACE PACKAGE BODY Cryptit AS
crypt_raw RAW(2000);
crypt_str VARCHAR(2000);
-- Encrypt the string --
FUNCTION encrypt(Str VARCHAR2) RETURN RAW AS
l INTEGER := LENGTH(str);
i INTEGER;
padblock RAW(2000);
Cle RAW(8) := UTL_RAW.CAST_TO_RAW('frankzap');
BEGIN
i := 8-MOD(l,8);
padblock := utl_raw.cast_to_raw(str||RPAD(CHR(i),i,CHR(i)));
dbms_obfuscation_toolkit.DESEncrypt(
input => padblock,
KEY => Cle,
encrypted_data => crypt_raw);
RETURN crypt_raw ;
END;
-- Encrypt the string with user supplied encryption key --
FUNCTION encrypt_with_key(Str VARCHAR2, key VARCHAR2) RETURN RAW AS
l INTEGER := LENGTH(str);
i INTEGER;
padblock RAW(2000);
Cle RAW(8) := UTL_RAW.CAST_TO_RAW(key);
BEGIN
i := 8-MOD(l,8);
padblock := utl_raw.cast_to_raw(str||RPAD(CHR(i),i,CHR(i)));
dbms_obfuscation_toolkit.DESEncrypt(
input => padblock,
KEY => Cle,
encrypted_data => crypt_raw);
RETURN crypt_raw ;
END;
-- Decrypt the string --
FUNCTION decrypt(xCrypt VARCHAR2) RETURN VARCHAR2 AS
l NUMBER;
Cle RAW(8) := UTL_RAW.CAST_TO_RAW('frankzap');
crypt_raw RAW(2000) := utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(xCrypt)) ;
BEGIN
dbms_obfuscation_toolkit.DESDecrypt(
input => xCrypt,
KEY => Cle,
decrypted_data => crypt_raw);
crypt_str := utl_raw.cast_to_varchar2(crypt_raw);
l := LENGTH(crypt_str);
crypt_str := RPAD(crypt_str,l-ASCII(SUBSTR(crypt_str,l)));
RETURN crypt_str;
END;
-- Decrypt the string with user supplied decryption key --
FUNCTION decrypt_with_key(xCrypt VARCHAR2, key VARCHAR2) RETURN VARCHAR2 AS
l NUMBER;
Cle RAW(8) := UTL_RAW.CAST_TO_RAW(key);
crypt_raw RAW(2000) := utl_raw.cast_to_raw(utl_raw.cast_to_varchar2(xCrypt)) ;
BEGIN
dbms_obfuscation_toolkit.DESDecrypt(
input => xCrypt,
KEY => Cle,
decrypted_data => crypt_raw);
crypt_str := utl_raw.cast_to_varchar2(crypt_raw);
l := LENGTH(crypt_str);
crypt_str := RPAD(crypt_str,l-ASCII(SUBSTR(crypt_str,l)));
RETURN crypt_str;
END;
END Cryptit;
/
사용 :
-- CRYPTIT functions usage example:
set echo on
set feedback on
set serveroutput on
DECLARE
LC$Code VARCHAR2(100) := 'Music is the best!' ;
BEGIN
-- Get the encrypted string --
LC$Code := Cryptit.Encrypt_with_key(LC$Code, 'yojoMama') ;
dbms_output.put_line(LC$Code) ;
-- Get the decrypted string --
LC$Code := Cryptit.Decrypt_with_key(LC$Code, 'yojoMama') ;
dbms_output.put_line(LC$Code) ;
END ;
/
create table conn_string
(
username varchar2(30),
crypt_conn varchar2(100),
instance varchar2(15)
)
;
insert into conn_string
values('CS_NOTEBOOK9', Cryptit.Encrypt_with_key('elnbukd452', 'yojoMama'), 'UKDEV452')
;
insert into conn_string
values('CS_NOTEBOOK9', Cryptit.Encrypt_with_key('elnbukt452', 'yojoMama'), 'UKTST452')
;
insert into conn_string
values('CS_NOTEBOOK9', Cryptit.Encrypt_with_key('elnbukv452', 'yojoMama'), 'UKVAL452')
;
insert into conn_string
values('CS_NOTEBOOK9', Cryptit.Encrypt_with_key('elnbukt452', 'yojoMama'), 'UKTRN452')
;
insert into conn_string
values('CS_NOTEBOOK9', Cryptit.Encrypt_with_key('elnbprd10', 'yojoMama'), 'UKPRD452')
;
insert into conn_string
values('CS_LTA', Cryptit.Encrypt_with_key('elnbprd10', 'yojoMama'), 'UKPRD452')
;
select
username
, crypt_conn
, Cryptit.Decrypt_with_key(crypt_conn, 'yojoMama') decrypt
, instance
from conn_string
;
rename conn_string to test_connect_details
;
create table test_set
(test_set_name varchar2(100)
, description varchar2(1000)
)
;
create table test_case
(test_set_name varchar2(100)
, test_name varchar2(100)
, description varchar2(1000)
)
;
create table test_piece
(test_set_name varchar2(100)
, test_name varchar2(100)
, piece_type varchar2(10)
, piece_order number (6,3)
, piece_text varchar2(4000)
)
;
select 'SQLPLUS ' || username
|| '/' || Cryptit.Decrypt_with_key(crypt_conn, 'yojoMama')
|| '@' || instance
|| ' ' || (select piece_text from test_piece b) cmd
from test_connect_details a
where upper(username) = 'CS_NOTEBOOK9'
and upper(instance) = 'UKDEV452'
;
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') date_run
, user
, instance_name
from v$instance;
'DBMS_CRYPTO'가 좋은 출발점입니다. 이 링크를 확인하십시오 -> https://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_crypto.htm#BJFGFDFG – g00dy
** 암호는 ** 암호화되어서는 안되며 ** 해시 **이어야합니다. 이것에 대해 혼동해서는 안됩니다. 그렇다면 현재 또는 미래에 나 자신에게 액세스 할 수있는 모든 환경에서 암호 보안을 담당하지 않기를 바랍니다. – mathguy