RSA in 4 lines of Scheme

Ulf Moeller Ulf_Moeller at public.uni-hamburg.de
Sat Jan 27 03:17:57 PST 1996


(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))






More information about the cypherpunks-legacy mailing list