{"id":496,"date":"2017-01-16T14:02:05","date_gmt":"2017-01-16T05:02:05","guid":{"rendered":"http:\/\/www.onepage.co.kr\/wordpress\/?p=496"},"modified":"2017-01-17T00:12:06","modified_gmt":"2017-01-16T15:12:06","slug":"ecryptiondecryptioninoracle","status":"publish","type":"post","link":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/2017\/01\/16\/ecryptiondecryptioninoracle\/","title":{"rendered":"\uc624\ub77c\ud074\uc758 \uc554\ud638\ud654\uc640 \ubcf5\ud638\ud654"},"content":{"rendered":"<p>&#8211;\uc624\ub77c\ud074\uc758 \uc554\ud638\ud654\uc640 \ubcf5\ud638\ud654<br \/>\n&#8211;\uc624\ub77c\ud074\uc758 \uc554\ud638\ud654\ub294 DBMS_OBFUSCATION_TOOLKIT\ub97c \uc774\uc6a9<br \/>\n&#8211;\uc774 \ud328\ud0a4\uc9c0\uc5d0\ub294 4\uac1c\uc758 \ud504\ub85c\uc2dc\uc800\uac00 \uc788\ub2e4.<br \/>\n&#8211;\ud504\ub85c\uc2dc\uc800\ub294 VARCHAR2 \ud0c0\uc785 \ubc0f RAW \ud0c0\uc785\uc744 \uc554\ud638\/\ubcf5\ud638\ud654 \uc9c0\uc6d0. \ub2e4\ub978 \ud0c0\uc785\uc740 \uc9c0\uc6d0\ub418\uc9c0 \uc54a\uc73c\ubbc0\ub85c NUMBER \ud0c0\uc785\uc740 TO_CHAR\ub97c \uc774\uc6a9\ud574\uc57c \ud55c\ub2e4.<br \/>\n&#8211;DBMS_OBFUSCATION_TOOLKIT \ud328\ud0a4\uc9c0\ub294 \uae30\ubcf8\uc801\uc73c\ub85c\ub294 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub294 \uc0c1\ud0dc\uc774\ub2e4. \uc124\uce58\uc2dc\uc5d0\ub294 \uc900\ube44 \ub418\uc9c0 \uc54a\uc740 \ud328\ud0a4\uc9c0\uc774\uae30 \ub54c\ubb38\uc774\ub2e4. \uc544\ub798 \ud30c\uc77c\uc744 \uc9c1\uc811 \uc2e4\ud589\ud574\uc57c \ud328\ud0a4\uc9c0\uac00 \uc0dd\uc131\ub418\uace0, \uc900\ube44\uac00 \ub41c\ub2e4.<br \/>\nD:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\dbmsobtk.sql<br \/>\nD:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\prvtobtk.plb<\/p>\n<p>&#8211;SQLPLUS\uc5d0\uc11c SYS\uacc4\uc815\uc73c\ub85c \ub85c\uadf8\uc778\ud55c \ud6c4 \uc2e4\ud589\ud569\ub2c8\ub2e4.<br \/>\nSQL&gt; @D:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\dbmsobtk.sql<br \/>\n&#8211;&gt;\ud328\ud0a4\uc9c0 \uc0dd\uc131<br \/>\nSQL&gt; @D:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\prvtobtk.plb<br \/>\n&#8211;&gt;\ud328\ud0a4\uc9c0 \ubcf8\ubb38 \uc0dd\uc131<br \/>\n&#8211;SYS: DBMS_OBFUSCATION_TOOLKIT \ud328\ud0a4\uc9c0\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \uad8c\ud55c\uc744 SCOTT \uc0ac\uc6a9\uc790\uc5d0\uac8c \ubd80\uc5ec<br \/>\nGRANT EXECUTE ON DBMS_OBFUSCATION_TOOLKIT TO scott;<br \/>\n&#8211;SYS: DBMS_OBFUSCATION_TOOLKIT \ud328\ud0a4\uc9c0\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \uad8c\ud55c\uc744 \ubaa8\ub4e0 \uc0ac\uc6a9\uc790\uc5d0\uac8c \ubd80\uc5ec<br \/>\nGRANT EXECUTE ON DBMS_OBFUSCATION_TOOLKIT TO PUBLIC;<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n&#8211;\uc554\ud638\ud654 \ubc0f \ubcf5\ud638\ud654\uc6a9 \ud328\ud0a4\uc9c0 \uc791\uc131<\/p>\n<p>(\uc0ac\uc6a9\ud560 \uacf3\uc5d0\uc11c \ud328\ud0a4\uc9c0 \uc0dd\uc131) \ub098\uc758 \uacbd\uc6b0\ub294 scott\uc5d0 \ud588\uc5c8\uc74c.<br \/>\n&#8211;\uc120\uc5b8<br \/>\nCREATE OR REPLACE PACKAGE CryptIT<br \/>\nIS<br \/>\nFUNCTION encrypt(str VARCHAR2, HASH VARCHAR2)<br \/>\nRETURN VARCHAR2;<br \/>\nFUNCTION decrypt(str VARCHAR2, HASH VARCHAR2)<br \/>\nRETURN VARCHAR2;<br \/>\nEND CryptIT;<\/p>\n<p>&#8211;\ubab8\uccb4<br \/>\nCREATE OR REPLACE PACKAGE BODY CryptIT<br \/>\nIS<br \/>\ns VARCHAR2(2000);<\/p>\n<p>FUNCTION encrypt(str VARCHAR2, HASH VARCHAR2) &#8212; \uc554\ud638\ud654<br \/>\nRETURN VARCHAR2<br \/>\nIS<br \/>\np NUMBER := ((FLOOR(LENGTH(str)\/8+0.9))*8);<br \/>\nBEGIN<br \/>\nDBMS_OBFUSCATION_TOOLKIT.DESEncrypt(<br \/>\ninput_string =&gt; RPAD(str,p)<br \/>\n,key_string =&gt; RPAD(HASH,8,&#8217;#&#8217;)<br \/>\n,encrypted_string =&gt; s<br \/>\n);<br \/>\nRETURN s;<br \/>\nEND;<br \/>\nFUNCTION decrypt(str VARCHAR2, HASH VARCHAR2) &#8212; \ubcf5\ud638\ud654<br \/>\nRETURN VARCHAR2<br \/>\nIS<br \/>\nBEGIN<br \/>\nDBMS_OBFUSCATION_TOOLKIT.DESDecrypt(<br \/>\ninput_string =&gt; str<br \/>\n,key_string =&gt; RPAD(HASH,8,&#8217;#&#8217;)<br \/>\n,decrypted_string =&gt; s<br \/>\n);<br \/>\nRETURN TRIM(s);<br \/>\nEND;<\/p>\n<p>END CryptIT;<br \/>\nCREATE TABLE abc(id NUMBER, pass VARCHAR2(20));<\/p>\n<p>INSERT INTO abc (id, pass) VALUES (1, CryptIT.encrypt(&#8216;12345&#8242;,&#8217;test&#8217;));<br \/>\nCOMMIT;<\/p>\n<p>SELECT id, pass FROM abc;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8211;\uc624\ub77c\ud074\uc758 \uc554\ud638\ud654\uc640 \ubcf5\ud638\ud654 &#8211;\uc624\ub77c\ud074\uc758 \uc554\ud638\ud654\ub294 DBMS_OBFUSCATION_TOOLKIT\ub97c \uc774\uc6a9 &#8211;\uc774 \ud328\ud0a4\uc9c0\uc5d0\ub294 4\uac1c\uc758 \ud504\ub85c\uc2dc\uc800\uac00 \uc788\ub2e4. &#8211;\ud504\ub85c\uc2dc\uc800\ub294 VARCHAR2 \ud0c0\uc785 \ubc0f RAW \ud0c0\uc785\uc744 \uc554\ud638\/\ubcf5\ud638\ud654 \uc9c0\uc6d0. \ub2e4\ub978 \ud0c0\uc785\uc740 \uc9c0\uc6d0\ub418\uc9c0 \uc54a\uc73c\ubbc0\ub85c NUMBER \ud0c0\uc785\uc740 TO_CHAR\ub97c \uc774\uc6a9\ud574\uc57c \ud55c\ub2e4. &#8211;DBMS_OBFUSCATION_TOOLKIT \ud328\ud0a4\uc9c0\ub294 \uae30\ubcf8\uc801\uc73c\ub85c\ub294 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub294 \uc0c1\ud0dc\uc774\ub2e4. \uc124\uce58\uc2dc\uc5d0\ub294 \uc900\ube44 \ub418\uc9c0 \uc54a\uc740 \ud328\ud0a4\uc9c0\uc774\uae30 \ub54c\ubb38\uc774\ub2e4. \uc544\ub798 \ud30c\uc77c\uc744 \uc9c1\uc811 \uc2e4\ud589\ud574\uc57c \ud328\ud0a4\uc9c0\uac00 \uc0dd\uc131\ub418\uace0, \uc900\ube44\uac00 \ub41c\ub2e4. D:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\dbmsobtk.sql D:\\oracle\\product\\10.2.0\\db_1\\RDBMS\\ADMIN\\prvtobtk.plb &#8211;SQLPLUS\uc5d0\uc11c SYS\uacc4\uc815\uc73c\ub85c \ub85c\uadf8\uc778\ud55c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-496","post","type-post","status-publish","format-standard","hentry","category-about-oracle"],"_links":{"self":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=496"}],"version-history":[{"count":1,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/496\/revisions"}],"predecessor-version":[{"id":497,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/496\/revisions\/497"}],"wp:attachment":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}