Here's my favorite piece of perl:<p>#!/usr/bin/perl -s<p><pre><code>                                                      @x=qw/e n d/;if(         
                               $kg){$e=13;$_="setrand(@{[int((rand)*90)]})     
                           ;K=vector(2,g,nextprime(random(10^$s)));e=$e;n=K[1]*
                               K[2];d=e^-1%((K[1]-1)*(K[2]-1));";s/\s//sg;for( 
                                `echo "$_ e\nn\nd\n"|gp -q`){print$x[$j++]     
                              ,"=",`echo "10i16o$_ p"|dc`}exit}$t=             
                             unpack'H*',join'',&#60;&#62;;$l=length$n;$y               
                          =$e?$l-2:$l;$i="16dio";while  (){$M=                 
                      ($e&#38;&#38;1+int(rand 8)).(substr     $t,$p                    
                   ,$y or last);$i.="\U$M $k        $n\E|                      
                pc";$p+=$y}for(reverse                                         
           `echo "$i"|dc`){chop                                                
   ;$d&#38;&#38;s/^(.)//||($_=                                                         
     sprintf"%0${l}s"                                                          
      ,$_); $f                                                                 
      .=$_}#                                                                   
      print                                                                    
      pack                                                                     
     'H*'                                                                      
   ,$f

</code></pre>
<a href="http://ftp.uk.debian.org/munitions/documents/rsafin.html" rel="nofollow">http://ftp.uk.debian.org/munitions/documents/rsafin.html</a>