Macro Library crypto
Cryptography functions, Nov 2, 2012
chunktext(text, size)
adds spaces between chunks of text of the given size
randfiveletterword()
returns a random five-letter word
randmilphrase([removespaces],[pad])
returns a random military-ish phrase like "at noon march towards target"
if removespaces is set to true, all spaces will be removed
if pad is set to a number N, then the phrase will be padded with random characters
for a transposition cipher with N columns.
shiftcipher(message, shift, [alpha] [rotate])
encrypts the message using a basic Caesar shift substitution cipher.
shift can be numeric value (e.g., 3 means A encrypts as D), or can be a letter
indicating what A encrypts as
alpha should be "alpha" for A-Z or "alphanum" for A-Z0-9. Defaults to "alpha"
if rotate is set to true, then the shift will be increased after each letter
is encrypted. Can set to a number to shift by more 1 after each letter.
randsubmap([charset])
generates a random substitution mapping
by default uses A-Z. Set charset="alphanum" or A-Z0-9
subcipher(message, submap, [alpha] [rotate])
encrypts the message using a general substitution cipher.
submap is a string consisting of all characters of the character set in
desired mapping order
alpha should be "alpha" for A-Z or "alphanum" for A-Z0-9. Defaults to "alpha"
if rotate is set to true, then the shift will be increased after each letter
is encrypted. Can set to a number to shift by more 1 after each letter.
transcipher(message, columns, [order])
encrypts a message using a basic transposition cipher, writing the message
in rows, each with the given number of columns. The encrypted message is
then formed by reading down the columns.
message is padded if needed with A's.
by default, the columns are read from left to right. If an array of numbers (0 to cols-1)
are provided for order, they will specify the order to read. If a word is
fed in for order, it will serve as the the code-word, and columsn will be read
in the alphabetic order of the letters in the word (e.g. day would mean 2 1 3
since a is the first of the letters in the alphabet, d is 2nd, etc)
modularexponent(base, exponent, modulus)
calculates base^exponent mod modulus
cryptorsakeys(p, q)
given two primes, p and q, returns array(n, e, d)
where n and e form the public key, and d is the private key