utils.encryption.js
When data is sent from the user's browser to the server there is always a way to steal that data. One way to reduce that risk is to encrypt the data with a one-way encryption such as MD5 or SHA and match it up later.
Method |
Code |
---|---|
UTILS.Encryption.sha1 |
//one-way encryption
UTILS.Encryption.sha1('my password'); //=> A2F8F7FA195A080A22A689041DAA8F2044F9F336
//extended prototype
'my password'.sha1Encode(); //=> A2F8F7FA195A080A22A689041DAA8F2044F9F336
|
UTILS.Encryption.base64.encode |
UTILS.Encryption.base64.encode('something to convert'); //=> c29tZXRoaW5nIHRvIGNvbnZlcnQ=
//extended prototype
'something to convert'.base64Encode(); //=> c29tZXRoaW5nIHRvIGNvbnZlcnQ=
|
UTILS.Encryption.base64.decode |
UTILS.Encryption.base64.decode('c29tZXRoaW5nIHRvIGNvbnZlcnQ='); //=> something to convert
//extended prototype
'c29tZXRoaW5nIHRvIGNvbnZlcnQ='.base64Decode(); //=> something to convert
|