thyCrypt

Class that manages cryptography.  It allow you to encrypt/decrypt things using one of the implemented cyphers.  (Now there’s just blowfish)

Summary
Class that manages cryptography.
Sets the cypher to be used.
Encodes the text passed with key
Decodes a base64 encoded string to the original one, if key is correct
Sets the random number generator function to be a custom one.

setCypher

p.setCypher = function (cypher)

Sets the cypher to be used.  Note that this method will call library include method, meaning that the the cypher will be available only on next run.

The only available cypher at the moment is blowfish.  (Rijndael comming...)

Parameter

cypherThe cypher type

encode

p.encode = function (str,
key)

Encodes the text passed with key

Parameters

strThe text to be encoded
keyThe key to be used to encode the text

Returns

Base64 encoded string

decode

p.decode = function (code,
key)

Decodes a base64 encoded string to the original one, if key is correct

Parameters

codeThe cyphered code
keyThe key to be used

setCustomRandomGenerator

p.setCustomRandomGenerator = function (rand)

Sets the random number generator function to be a custom one.  If not called, the class will use the default one.

Parameters

randThe function to be called
p.setCypher = function (cypher)
Sets the cypher to be used.
p.encode = function (str,
key)
Encodes the text passed with key
p.decode = function (code,
key)
Decodes a base64 encoded string to the original one, if key is correct
p.setCustomRandomGenerator = function (rand)
Sets the random number generator function to be a custom one.