in reply to The Exponentiation of (not-so) Large Primes

To quote http://world.std.com/~franl/crypto/rsa-guts.html

RSA in 2 Lines of Perl

Adam Back (aba@dcs.exeter.ac.uk) has created an implementation of RSA in just 2 lines of Perl. It uses <KBD>dc</KBD>, an arbritrary precision arithmetic package that ships with most UNIX systems. Here's the Perl code:

print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*" +,<> )]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"| +dc`

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Replies are listed 'Best First'.
Re^2: The Exponentiation of (not-so) Large Primes
by titivillus (Scribe) on Jun 29, 2006 at 04:55 UTC
    Yes, this is years late, but I'm just back from YAPC::NA and back in a Perl state of mind. I started out saying that I wanted a pure Perl implementation. The description you link to says.
    It uses dc, an arbritrary precision arithmetic package that ships with most UNIX systems.
    That isn't quite what I was hoping for. And, y'know? Those two-line implementations of things are exactly why people have a bad view of Perl. Yes, it's wonderful and cool that such a small implementation exists. But I was hoping to put this together for a presentation for my LUG, and having code that someone who isn't a full-on Perl guru can look at and understand is a good thing when you're trying to teach it. I don't want to be harsh -- you were trying to help -- and I do suck for abandoning this thought for four years. It's just that the cool 2-line implementation that calls dc isn't what I need.

    .sig goes here

      You are 100% correct! That said I would recommend the following for your presentation; go ahead and show the Perl code, explain your criticisms and then demonstrate a workable version either in Perl or (my choice) Mathematica. Perhaps a headline such as "When go answers go bad" or some such.

      --hsm

      "Never try to teach a pig to sing...it wastes your time and it annoys the pig."