#!/usr/bin/perl -s @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'',<>;$l=length$n;$y =$e?$l-2:$l;$i="16dio";while (){$M= ($e&&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&&s/^(.)//||($_= sprintf"%0${l}s" ,$_); $f .=$_}# print pack 'H*' ,$f # RSA Encryption, Decryption and Key Generation with Perl/dc/gp. # Copyright (c) 1998-2000, Vipul Ved Prakash. # http://munitions.vipul.net/documents/rsafin.html # $Id: fin,v 0.10 1999/01/25 23:24:37 root Exp root $ # Syntax: # To generate 1024-bit key: fin -kg -s=155 # To generate 2048-bit key: fin -kg -s=309 (Takes a while.) # To encrypt/decrypt: fin -k=key -n=rsa_modulus [-e/-d] files.