{"id":789,"date":"2009-12-01T16:24:06","date_gmt":"2009-12-01T16:24:06","guid":{"rendered":"http:\/\/pchero21.com\/?p=789"},"modified":"2009-12-01T16:24:06","modified_gmt":"2009-12-01T16:24:06","slug":"openssl-random-%ed%95%a8%ec%88%98-%ec%82%ac%ec%9a%a9%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/pchero21.com\/?p=789","title":{"rendered":"OpenSSL-RANDOM \ud568\uc218 \uc0ac\uc6a9\ud558\uae30"},"content":{"rendered":"<blockquote><p>\n<P>#include &lt;stdio.h&gt;<br \/>#include &lt;openssl\/err.h&gt;<br \/>#include &lt;openssl\/rand.h&gt;<\/P><br \/>\n<P>int main(int argc, char* argv[])<br \/>{<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int i;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; int retVal = 0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub79c\ub364 \uc218\uc758 \uae38\uc774\ub294 64\ub85c \ud55c\ub2e4.<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; int length = 64;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ PRNG\uc5d0 \uacf5\uae09\ud560 seed \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; RAND_status();<br \/>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \uc0dd\uc131\ud560 \ub79c\ub364 \uc218 \uae38\uc774\ub9cc\ud07c\uc758 \ubc84\ud37c \uc0dd\uc131<br \/>&nbsp; &nbsp; &nbsp; &nbsp; unsigned char *buffer = (unsigned char*)malloc(sizeof(unsigned char) * length);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ run PRNG<br \/>&nbsp; &nbsp; &nbsp; &nbsp; retVal = RAND_bytes(buffer, length);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; if(retVal &lt;= 0) {<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;error encount!n&#8221;);<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 0;<br \/>&nbsp; &nbsp; &nbsp; &nbsp; }<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ print random number<br \/>&nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;Random number = &#8220;);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; for(i = 0; i &lt; length; i++)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf(&#8220;%c&#8221;, buffer[i]);<\/P><br \/>\n<P>&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br \/>}<\/P><\/BLOCKQUOTE><br \/>\n<P>&nbsp;<\/P><br \/>\n<P>&nbsp;Windows\uc758 \uacbd\uc6b0 RAND_status() \ub97c RAND_screen() \uc73c\ub85c \ubc14\uafd4\uc8fc\uba74 \ub41c\ub2e4.<\/P><br \/>\n<P>&nbsp;<\/P><br \/>\n<P><br \/><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt;#include &lt;openssl\/err.h&gt;#include &lt;openssl\/rand.h&gt; int main(int argc, char* argv[]){&nbsp; &nbsp; &nbsp; &nbsp; int i;&nbsp; &nbsp; &nbsp; &nbsp; int retVal = 0;&nbsp; &nbsp; &nbsp; &nbsp; \/\/ \ub79c\ub364 \uc218\uc758 \uae38\uc774\ub294 64\ub85c \ud55c\ub2e4. &nbsp; &nbsp; &nbsp; &nbsp; int length = 64;&nbsp; &nbsp; &nbsp; &hellip; <a href=\"http:\/\/pchero21.com\/?p=789\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[53],"tags":[297,362],"_links":{"self":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/789"}],"collection":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=789"}],"version-history":[{"count":0,"href":"http:\/\/pchero21.com\/index.php?rest_route=\/wp\/v2\/posts\/789\/revisions"}],"wp:attachment":[{"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=789"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pchero21.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}