[48269] in Cypherpunks

home help back first fref pref prev next nref lref last post

RSA in 4 lines of Scheme

daemon@ATHENA.MIT.EDU (Ulf Moeller)
Sat Jan 27 05:55:50 1996

To: cypherpunks@toad.com
Date: Sat, 27 Jan 1996 11:38:31 +0100 (MET)
Reply-To: Ulf_Moeller@public.uni-hamburg.de (Ulf Moeller)
From: Ulf_Moeller@public.uni-hamburg.de (Ulf Moeller)

(define(RSA m e n)(list->string(u(r(s(string->list m))e n))))(define(u a)(if(>
a 0)(cons(integer->char(modulo a 256))(u(quotient a 256)))'()))(define(s a)(if
(null? a)0(+(char->integer(car a))(* 256(s(cdr a))))))(define(r a x n)(cond((=
0 x)1)((even? x)(modulo(expt(r a(/ x 2)n)2)n))(#t(modulo(* a(r a(1- x)n))n))))

                                    ;;;;
                                    ;;;;

(define c (RSA "The magic words are squeamish ossifrage" 5 114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541))
(display (RSA c 45752650303155547067694311990458644804087318688496945025024737159778909096647814932594914301288138204957467016445183857236173773 114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541))

home help back first fref pref prev next nref lref last post