These are the Functions for a simple RSA Encryption and Decryption with Mathematica. To generate your own Public and Private Keys you need the Package "RSA.m" by Stephan Kaufmann.
(* This is a Mathematica Cell to encrypt *) (* Text Messages with RSA *) (* by Felix Holderied (felix@holderied.de) *) n = 36997643846908076023169992376070964783978488234097; e = 3706053460201685537065951298503672281853801754175; " PLEASE FILL IN YOUR MESSAGE HERE, EVALUATE THE CELL AND SEND ME THE OUTPUT "; ToCharacterCode[%]; Fold[#1 256 + #2&, 0, %]; IntegerDigits[%,n]; Function[x,PowerMod[x, e, n]] /@ % |
(* This is a Mathematica Cell to decrypt *)
(* Text Messages with RSA *)
(* by Felix Holderied (felix@holderied.de) *)
n =
36997643846908076023169992376070964783978488234097;
d =
13703995578038648077146655859342031523719625182575;
{THIS SHOULD BE THE ENCRYPTED LIST};
Function[x,PowerMod[x, d, n]] /@ %;
Fold[#1 n + #2&, 0, %];
IntegerDigits[%,256];
FromCharacterCode[%]
|