{"id":17294,"date":"2019-06-28T12:15:38","date_gmt":"2019-06-28T17:15:38","guid":{"rendered":"http:\/\/bucktownbell.com\/?p=17294"},"modified":"2019-06-28T12:17:25","modified_gmt":"2019-06-28T17:17:25","slug":"rsa-in-5-lines-of-perl","status":"publish","type":"post","link":"http:\/\/bucktownbell.com\/?p=17294","title":{"rendered":"RSA in 5 lines of perl"},"content":{"rendered":"<p style=\"padding-left: 30px;\"><code>#!\/usr\/local\/bin\/perl -s do 'bigint.pl';<\/code><\/p>\n<p style=\"padding-left: 30px;\"><code>($_,$n)=@ARGV;s\/^.(..)*$\/0$&amp;\/;<\/code><\/p>\n<p style=\"padding-left: 30px;\"><code>($k=unpack('B*',pack('H*',$_)))=~ s\/^0*\/\/;<\/code><\/p>\n<p style=\"padding-left: 30px;\"><code>$x=0;$z=$n=~s\/.\/$x=&amp;badd(&amp;bmul($x,16),hex$&amp;)\/ge;<\/code><\/p>\n<p style=\"padding-left: 30px;\"><code>while(read(STDIN,$_,$w =((2*$d-1+$z)&amp;~1)\/2)){$r=1;$_=substr($_.\"\\0\"x$w,$c=0,$w);<\/code><\/p>\n<p style=\"padding-left: 30px;\"><code>s\/.|\\n\/$c=&amp;badd(&amp;bmul ($c,256),ord$&amp;)\/ge;$_=$k;s\/.\/$r=&amp;bmod(&amp;bmul($r,$r),$x),$&amp;?$r=&amp;bmod(&amp;bmul($r,$c ),$x):0,\"\"\/ge;($r,$t)=&amp;bdiv($r,256),$_=pack(C,$t).$_ while$w--+1-2*$d;print}<\/code><\/p>\n<p>Source: <em><a href=\"http:\/\/www.cypherspace.org\/rsa\/pureperl.html\">RSA in 5 lines of perl<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/usr\/local\/bin\/perl -s do &#8216;bigint.pl&#8217;; ($_,$n)=@ARGV;s\/^.(..)*$\/0$&amp;\/; ($k=unpack(&#8216;B*&#8217;,pack(&#8216;H*&#8217;,$_)))=~ s\/^0*\/\/; $x=0;$z=$n=~s\/.\/$x=&amp;badd(&amp;bmul($x,16),hex$&amp;)\/ge; while(read(STDIN,$_,$w =((2*$d-1+$z)&amp;~1)\/2)){$r=1;$_=substr($_.&#8221;\\0&#8243;x$w,$c=0,$w); s\/.|\\n\/$c=&amp;badd(&amp;bmul ($c,256),ord$&amp;)\/ge;$_=$k;s\/.\/$r=&amp;bmod(&amp;bmul($r,$r),$x),$&amp;?$r=&amp;bmod(&amp;bmul($r,$c ),$x):0,&#8221;&#8221;\/ge;($r,$t)=&amp;bdiv($r,256),$_=pack(C,$t).$_ while$w&#8211;+1-2*$d;print} Source: RSA in 5 lines of perl<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[338,171,1190,185],"class_list":["post-17294","post","type-post","status-publish","format-standard","hentry","category-programming","tag-encryption","tag-perl","tag-rsa","tag-wtf"],"_links":{"self":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/17294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17294"}],"version-history":[{"count":4,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/17294\/revisions"}],"predecessor-version":[{"id":17298,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=\/wp\/v2\/posts\/17294\/revisions\/17298"}],"wp:attachment":[{"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17294"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bucktownbell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}