[Home] [Help]
PACKAGE BODY: APPS.AMS_IMPORT_SECURITY_PVT
Source
1 PACKAGE BODY AMS_Import_Security_PVT as
2 /* $Header: amsvimsb.pls 115.6 2004/04/20 01:58:52 sranka ship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 -- AMS_Import_Security_PVT
7 -- Purpose
8 --
9 -- History
10 -- 07-Nov-2002 HUILI Created
11 --
12 -- NOTE
13 --
14 -- End of Comments
15 -- ===============================================================
16 G_HASH_FORMAT CONSTANT VARCHAR2(2000) := rpad( 'X',29,'X')||'X';
17 G_HARD_CODE_KEY CONSTANT VARCHAR2(20) := 'AMSIMPORT';
18
19 PROCEDURE Get_Encrypt_Key (
20 p_import_header_id IN NUMBER,
21 x_key OUT NOCOPY VARCHAR2
22 )
23 IS
24 CURSOR c_get_created_by (p_imp_header_id IN NUMBER) IS
25 SELECT CREATED_BY
26 FROM AMS_IMP_LIST_HEADERS_ALL
27 WHERE IMPORT_LIST_HEADER_ID = p_imp_header_id;
28 l_created_by NUMBER;
29 BEGIN
30 OPEN c_get_created_by (p_import_header_id);
31 FETCH c_get_created_by INTO l_created_by;
32 CLOSE c_get_created_by;
33
34 x_key :=
35 ltrim( to_char( dbms_utility.get_hash_value(p_import_header_id || l_created_by,1000000000, power(2,30) ), G_HASH_FORMAT) );
36 END Get_Encrypt_Key;
37
38 FUNCTION Get_DeEncrypt_String (
39 p_input_string IN VARCHAR2,
40 p_header_id IN NUMBER,
41 p_encrypt_flag IN BOOLEAN -- field to indicate whether it is
42 -- encrypt or decrypt
43 ) RETURN VARCHAR2
44 IS
45 l_key VARCHAR2(2000);
46 l_out_string VARCHAR2(2000);
47 l_length NUMBER;
48 l_input_string VARCHAR2(2000);
49
50 BEGIN
51 IF p_header_id IS NULL THEN
52 l_key := G_HARD_CODE_KEY;
53 ELSE
54 Get_Encrypt_Key (
55 p_import_header_id => p_header_id,
56 x_key => l_key
57 );
58 END IF;
59
60 IF p_encrypt_flag THEN
61 l_length := (trunc(length(p_input_string)/8)+1)*8;
62 l_input_string := p_input_string;
63 WHILE length(l_input_string) < l_length
64 LOOP
65 l_input_string := l_input_string || chr(0);
66 END LOOP;
67 dbms_obfuscation_toolkit.DESEncrypt(
68 --input_string => rpad(p_input_string, (trunc(length(p_input_string)/8)+1)*8, chr(0) ),
69 input_string => l_input_string,
70 key_string => l_key,
71 encrypted_string => l_out_string);
72 ELSE
73 dbms_obfuscation_toolkit.DESDecrypt(
74 input_string => p_input_string,
75 key_string => l_key,
76 decrypted_string => l_out_string);
77 l_out_string := rtrim (l_out_string, chr(0));
78 END IF;
79 RETURN l_out_string;
80 END Get_DeEncrypt_String;
81
82
83 END AMS_Import_Security_PVT;