{"id":294,"date":"2011-12-14T02:15:24","date_gmt":"2011-12-14T02:15:24","guid":{"rendered":"http:\/\/brain.dailyon.net\/?p=294"},"modified":"2011-12-14T02:15:24","modified_gmt":"2011-12-14T02:15:24","slug":"oracle-%ec%95%94%ed%98%b8%ed%99%94-%ed%8c%a8%ed%82%a4%ec%a7%80-%ec%84%a4%ec%b9%98","status":"publish","type":"post","link":"https:\/\/blog.goorigo.com\/?p=294","title":{"rendered":"ORACLE : \uc554\ud638\ud654 \ud328\ud0a4\uc9c0 \uc124\uce58"},"content":{"rendered":"<p><a href=\"http:\/\/aozjffl.tistory.com\/158\">http:\/\/aozjffl.tistory.com\/158<\/a><\/p>\n<p>\uc624\ub77c\ud074 \uc554\ud638\ud654 &nbsp;\ud328\ud0a4\uc9c0 \uc124\uce58\ud558\uae30<\/p>\n<p>\uc124\uce58\uc5d0 \uc2e4\ud328\ud558\uba74 \uc77c\ub2e8 \ud328\ud0a4\uc9c0\ub97c \uae54\ub054\ud558\uac8c \uc9c0\uc6b0\uc790<\/p>\n<p>\uc0ad\uc81c\ubc29\ubc95 : drop package \ud328\ud0a4\uc9c0\uba85;<\/p>\n<p>\uac80\uc0c9 \ubc29\ubc95 : select *&nbsp;from user_source&nbsp;where name = &#8216;PROC1&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000\">DBMS_OBFUSCATION_TOOLKIT \uc758 \uc554\ud638\ud654\/\ubcf5\ud638\ud654<br \/>\n<\/span><\/p>\n<p>1. \uc124 \uba85<\/p>\n<p>\u261e Bulletin no : 12036 \ucc38\uace0<\/p>\n<p>&nbsp;<br \/>\nOracle 8i Release2(8.1.6)\uc5d0\uc11c\ub294 \ub370\uc774\ud130\ub97c \uc554\ud638\ud654\ud558\uc5ec \uc800\uc7a5\ud560 \uc218 \uc788\ub294&nbsp;<br \/>\n\ud5a5\uc0c1\ub41c \uae30\ub2a5(DES Encryption)\uc744 \uc81c\uacf5 \ud569\ub2c8\ub2e4<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n\uc989 \uc2e0\uc6a9\uce74\ub4dc\ubc88\ud638, \ud328\uc2a4\uc6cc\ub4dc \ub4f1 \ubcf4\uc548\uc774 \ud544\uc694\ud55c \ub370\uc774\ud130\ub97c \uc554\ud638\ud654\ub41c \ud615\ud0dc\ub85c \uc800\uc7a5\ud558\uc5ec<br \/>\n\uae30\uc874\uc758 3rd Party Tool\uc774\ub098, Application Logic\uc73c\ub85c \uad6c\ud604\ud558\ub358 \uc554\ud638\ud654 \uc815\ucc45\uc744<br \/>\n\ub370\uc774\ud130\ubca0\uc774\uc2a4 \ucc28\uc6d0\uc5d0\uc11c \uad6c\ud604\ud560 \uc218 \uc788\ub3c4\ub85d \ud574\uc90d\ub2c8\ub2e4.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n\u25c8 DBMS_OBFUSCATION_TOOLKIT<\/p>\n<p>\uc554\ud638\ud654 \uae30\ub2a5\uc744 \uc774\uc6a9\ud558\ub824\uba74 DBMS_OBFUSCATION_TOOLKIT\uc744 \uc774\uc6a9\ud574\uc57c \ud569\ub2c8\ub2e4.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n\uc774 \ud328\ud0a4\uc9c0\ub294 4\uac1c\uc758 \ud504\ub85c\uc2dc\uc838\ub85c \uc774\ub8e8\uc5b4\uc838 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>&#8211; VARCHAR2 \ud0c0\uc785\uc744 Encrypt\/Decrypt\ud560 \uc218 \uc788\ub294 2\uac1c\uc758 \ud504\ub85c\uc2dc\uc838<\/p>\n<p>&#8211; RAW \ud0c0\uc785\uc744 Encrypt\/Decrypt\ud560 \uc218 \uc788\ub294 2\uac1c\uc758 \ud504\ub85c\uc2dc\uc838<br \/>\n(\ub2e4\ub978 \ud0c0\uc785\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\uc73c\ubbc0\ub85c number\uc778 \uacbd\uc6b0\ub294 to_char \uc774\uc6a9)<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>DBMS_OBFUSCATION_TOOLKIT\uc744 \uc774\uc6a9\ud558\uae30 \uc704\ud574\uc11c\ub294 :<\/p>\n<p>1) SYS \uc720\uc800\ub85c \uc544\ub798\uc758 \uc2a4\ud06c\ub9bd\ud2b8\ub97c \uc2e4\ud589 \uc2dc\ud0b5\ub2c8\ub2e4.<\/p>\n<p>&nbsp;&nbsp; @$ORACLE_HOME\/rdbms\/admin\/dbmsobtk.sql<br \/>\n&nbsp;&nbsp; @$ORACLE_HOME\/rdbms\/admin\/prvtobtk.plb<br \/>\n&nbsp;&nbsp;&nbsp;<br \/>\n2) \uad8c\ud55c\uc744 \ubd80\uc5ec \ud569\ub2c8\ub2e4.<\/p>\n<p>&nbsp;&nbsp; SQL&gt;GRANT execute ON dbms_obfuscation_toolkit TO public;<\/p>\n<p>&nbsp;<\/p>\n<p>2. \ud328\ud0a4\uc9c0 \uc2e4\ud589\ud558\uae30<\/p>\n<p>&nbsp;<\/p>\n<p>&#8211;&gt; \ud328\ud0a4\uc9c0 \uc120\uc5b8\ubd80 \uc0dd\uc131<\/p>\n<p>CREATE OR REPLACE PACKAGE CryptIT AS&nbsp;<br \/>\n&nbsp;&nbsp; FUNCTION encrypt( Str VARCHAR2,&nbsp;&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash VARCHAR2 ) RETURN VARCHAR2;<\/p>\n<p>&nbsp;&nbsp; FUNCTION decrypt( xCrypt VARCHAR2,<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash VARCHAR2 ) RETURN VARCHAR2;<\/p>\n<p>&nbsp;&nbsp; FUNCTION md5( Str VARCHAR2) RETURN VARCHAR2;<\/p>\n<p>END CryptIT;<br \/>\n\/<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&#8211;&gt; \ud328\ud0a4\uc9c0 \ubcf8\uccb4 \uc0dd\uc131<\/p>\n<p>CREATE OR REPLACE PACKAGE BODY CryptIT AS&nbsp;<br \/>\n&nbsp;&nbsp; crypted_string VARCHAR2(2000);<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp; FUNCTION encrypt( Str VARCHAR2,&nbsp;&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash VARCHAR2 ) RETURN VARCHAR2 AS<br \/>\n&nbsp;&nbsp; pieces_of_eight INTEGER := ((FLOOR(LENGTH(Str)\/8 + .9)) * 8);<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp; BEGIN<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_obfuscation_toolkit.DESEncrypt(<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input_string&nbsp;&nbsp;&nbsp;&nbsp; =&gt; RPAD( Str, pieces_of_eight ),<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; RPAD(hash,8,&#8217;#&#8217;),&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; encrypted_string =&gt; crypted_string );<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETURN crypted_string;<br \/>\n&nbsp;&nbsp; END;<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp; FUNCTION decrypt( xCrypt VARCHAR2,<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hash VARCHAR2 ) RETURN VARCHAR2 AS&nbsp;<br \/>\n&nbsp;&nbsp; BEGIN<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_obfuscation_toolkit.DESDecrypt(<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input_string&nbsp;&nbsp;&nbsp;&nbsp; =&gt; xCrypt,&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key_string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; RPAD(hash,8,&#8217;#&#8217;),&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decrypted_string =&gt; crypted_string );<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETURN trim(crypted_string);<br \/>\n&nbsp;&nbsp; END;<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp; FUNCTION md5( Str VARCHAR2) RETURN VARCHAR2 AS<\/p>\n<p>&nbsp;&nbsp; BEGIN<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_obfuscation_toolkit.MD5(<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input_string =&gt; :input_string,<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checksum_string =&gt; :checksum_string);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RETURN trim(crypted_string);<br \/>\n&nbsp;&nbsp; END;<br \/>\nEND CryptIT;<br \/>\n\/<\/p>\n<p>&nbsp;<\/p>\n<p>\n3. \uc2e4\ud589 \uc608\uc81c<\/p>\n<p>\n1) Encrypt\ud558\uc5ec \ub370\uc774\ud130 \uc785\ub825<\/p>\n<p>&#8212; \ud14c\uc2a4\ud2b8 \ud14c\uc774\ube14\uc744 \uc0dd\uc131 \ud569\ub2c8\ub2e4.<\/p>\n<p>SQL&gt;create table encrypt_table( id number, passwd varchar(20) );<\/p>\n<p>\n&nbsp;<br \/>\n&#8212; \ud14c\uc2a4\ud2b8 \ub370\uc774\ud2b8\ub7f4 \uc785\ub825 \ud569\ub2c8\ub2e4.&nbsp;<br \/>\n&#8212; CryptIT.encrypt(\ube44\ubc00\ubc88\ud638, \ud0a4\uac12)<\/p>\n<p>SQL&gt;INSERT INTO encrypt_table VALUES( 1, CryptIT.encrypt(&#8216;1234&#8217;, &#8216;storm&#8217;));<br \/>\n1 \uac1c\uc758 \ud589\uc774 \ub9cc\ub4e4\uc5b4\uc84c\uc2b5\ub2c8\ub2e4.<\/p>\n<p>&nbsp;<br \/>\nSQL&gt;INSERT INTO encrypt_table VALUES( 2, CryptIT.encrypt(&#8216;5678&#8217;, &#8216;oramaster&#8217;));<br \/>\n1 \uac1c\uc758 \ud589\uc774 \ub9cc\ub4e4\uc5b4\uc84c\uc2b5\ub2c8\ub2e4.<\/p>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n2) Decrypt\ud558\uc5ec \ub370\uc774\ud130 \uc870\ud68c<br \/>\n&nbsp;<br \/>\n&#8211;&gt; Decrypt\ud558\uc9c0 \uc54a\uc73c\uba74 \uc554\ud638\ud654\ub41c \ub370\uc774\ud130\uc640 \ube44\uad50\ub418\uc11c \uacb0\uacfc\uac12\uc774 \ucd9c\ub825\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<br \/>\nSQL&gt; select id, passwd from encrypt_table where passwd = &#8216;1234&#8217;;<br \/>\n&nbsp;<br \/>\n\uc120\ud0dd\ub41c \ub808\ucf54\ub4dc\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&#8211;&gt; \uc800\uc7a5\uc7a5\uce58\uc5d0 Encrypt\ub41c \uac12\uc73c\ub85c \uc800\uc7a5 \ub429\ub2c8\ub2e4.<\/p>\n<p>SQL&gt; col passwd format a60<br \/>\nSQL&gt; select id, dump(passwd) passwd from encrypt_table;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ID PASSWD<br \/>\n&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 Typ=1 Len=8: 246,27,80,184,227,225,245,31<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 Typ=1 Len=8: 175,231,213,125,85,223,46,133<br \/>\n&nbsp;<\/p>\n<p>\n&#8211;&gt; Encrypt\ud560 \ub54c \uc0ac\uc6a9\ud55c Key\ub85c\ub9cc Decrypt\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br \/>\n&nbsp;<br \/>\nSQL&gt;SELECT id, CryptIT.decrypt(passwd,&#8217;storm&#8217;) passwd<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM encrypt_table&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE CryptIT.decrypt(passwd,&#8217;storm&#8217;) = &#8216;1234&#8217;;<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ID PASSWD<br \/>\n&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8211;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 1234<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\nSQL&gt;SELECT id, CryptIT.decrypt(passwd,&#8217;oramaster&#8217;) passwd<br \/>\n&nbsp;&nbsp;&nbsp; FROM encrypt_table&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp; WHERE CryptIT.decrypt(passwd,&#8217;oramaster&#8217;) = &#8216;5678&#8217;;<br \/>\n&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ID PASSWD<br \/>\n&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8211;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 5678<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n\uc8fc\uc758) Table\uc5d0 \uc811\uadfc \uad8c\ud55c\uc774 \uc788\ub294 \ub2e4\ub978 \uc720\uc800\ub3c4 Key\uac12\uc744 \uc54c\uba74 Decrypt\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n4) \uad00\ub828 ORA error number<br \/>\n&nbsp;<br \/>\nORA error 28231 &#8220;Invalid input to Obfuscation toolkit&#8221;<br \/>\n&#8211; input data, key\uac12\uc774 NULL\uc77c \uacbd\uc6b0 \ubc1c\uc0dd<br \/>\n&nbsp;<br \/>\nORA error 28232 &#8220;Invalid input size for Obfuscation toolkit&#8221;<br \/>\n&#8211; input data\uac00 8 bytes \ubc30\uc218\uac00 \uc544\ub2d0 \uacbd\uc6b0 \ubc1c\uc0dd<br \/>\n&nbsp;<br \/>\nORA error 28233 &#8220;Double encryption not supported by DESEncrypt in Obfuscation toolkit&#8221;<br \/>\n&#8211; encrypt data\ub97c \ub2e4\uc2dc encrypt\uacbd\uc6b0 \ubc1c\uc0dd<br \/>\n&nbsp;<\/p>\n<p>\uad00 \ub828 \uc790 \ub8cc<br \/>\n===========<br \/>\nOracle8i Supplied PL\/SQL Packages Reference Release 2 (8.1.6)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/aozjffl.tistory.com\/158 \uc624\ub77c\ud074 \uc554\ud638\ud654 &nbsp;\ud328\ud0a4\uc9c0 \uc124\uce58\ud558\uae30 \uc124\uce58\uc5d0 \uc2e4\ud328\ud558\uba74 \uc77c\ub2e8 \ud328\ud0a4\uc9c0\ub97c \uae54\ub054\ud558\uac8c \uc9c0\uc6b0\uc790 \uc0ad\uc81c\ubc29\ubc95 : drop package \ud328\ud0a4\uc9c0\uba85; \uac80\uc0c9 \ubc29\ubc95 : select *&nbsp;from user_source&nbsp;where name = &#8216;PROC1&#8217;; &nbsp; DBMS_OBFUSCATION_TOOLKIT \uc758 \uc554\ud638\ud654\/\ubcf5\ud638\ud654 1.&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=\/wp\/v2\/posts\/294"}],"collection":[{"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":0,"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.goorigo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}