Package Exports
- crypto-ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (crypto-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
crypto-ts
Typescript library of crypto standards. Ready for AOT and treeshaking in combination with Angular and other modern typescript frameworks.
Node.js (Install)
Requirements:
- Node.js
- npm (Node.js package manager)
npm install crypto-tsUsage
ES6 import for typical API call signing use case:
import { AES } from 'crypto-ts';
const encryptedMessage = AES.encrypt('message', 'test').toString();Modular include:
var AES = require("crypto-ts").AES;
var SHA256 = require("crypto-ts").SHA256;
...
console.log(SHA256("Message"));Including all libraries, for access to extra methods:
var CryptoTS = require("crypto-ts");
...
console.log(CryptoTS.HmacSHA1("Message", "Key"));Client (browser)
Requirements:
- Node.js
- Bower (package manager for frontend)
bower install crypto-tsUsage
Modular include:
require.config({
packages: [
{
name: 'crypto-ts',
location: 'path-to/bower_components/crypto-ts',
main: 'index'
}
]
});
require(["crypto-ts/algo/aes", "crypto-ts/algo/sha256"], function (AES, SHA256) {
console.log(SHA256("Message"));
});Including all libraries, for access to extra methods:
// Above-mentioned will work or use this simple form
require.config({
paths: {
'crypto-ts': 'path-to/bower_components/crypto-ts/crypto-ts'
}
});
require(["crypto-ts"], function (CryptoTS) {
console.log(CryptoTS.MD5("Message"));
});Usage without RequireJS
<script type="text/javascript" src="path-to/bower_components/crypto-ts/crypto-ts.js"></script>
<script type="text/javascript">
var encrypted = CryptoTS.AES(...);
var encrypted = CryptoTS.SHA256(...);
</script>AES Encryption
Plain text encryption
var CryptoTS = require("crypto-ts");
// Encrypt
var ciphertext = CryptoTS.AES.encrypt('my message', 'secret key 123');
// Decrypt
var bytes = CryptoTS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var plaintext = bytes.toString(CryptoTS.enc.Utf8);
console.log(plaintext);Object encryption
var CryptoTS = require("crypto-ts");
var data = [{id: 1}, {id: 2}]
// Encrypt
var ciphertext = CryptoTS.AES.encrypt(JSON.stringify(data), 'secret key 123');
// Decrypt
var bytes = CryptoTS.AES.decrypt(ciphertext.toString(), 'secret key 123');
var decryptedData = JSON.parse(bytes.toString(CryptoTS.enc.Utf8));
console.log(decryptedData);List of modules
crypto-ts/corecrypto-ts/x64-corecrypto-ts/lib-typedarrays
crypto-ts/md5crypto-ts/sha1crypto-ts/sha256crypto-ts/sha224crypto-ts/sha512crypto-ts/sha384crypto-ts/sha3crypto-ts/ripemd160
crypto-ts/hmac-md5crypto-ts/hmac-sha1crypto-ts/hmac-sha256crypto-ts/hmac-sha224crypto-ts/hmac-sha512crypto-ts/hmac-sha384crypto-ts/hmac-sha3crypto-ts/hmac-ripemd160
crypto-ts/pbkdf2
crypto-ts/aescrypto-ts/tripledescrypto-ts/rc4crypto-ts/rabbitcrypto-ts/rabbit-legacycrypto-ts/evpkdf
crypto-ts/format-opensslcrypto-ts/format-hex
crypto-ts/enc-latin1crypto-ts/enc-utf8crypto-ts/enc-hexcrypto-ts/enc-utf16crypto-ts/enc-base64
crypto-ts/mode-cfbcrypto-ts/mode-ctrcrypto-ts/mode-ctr-gladmancrypto-ts/mode-ofbcrypto-ts/mode-ecb
crypto-ts/pad-pkcs7crypto-ts/pad-ansix923crypto-ts/pad-iso10126crypto-ts/pad-iso97971crypto-ts/pad-zeropaddingcrypto-ts/pad-nopadding