simply-crypt js test added

This commit is contained in:
jngrt 2014-05-15 23:10:26 +02:00
parent 03f3fef866
commit afae0b552e
4 changed files with 8085 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

44
js-crypt-test/test.html Normal file
View File

@ -0,0 +1,44 @@
<html>
<script type="text/javascript" src="js/simple-crypt-deps.js"></script>
<script type="text/javascript" src="js/simple-crypt.js"></script>
<script>
// With these keys it works!
var priv_pem = "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEA4qiw8PWs7PpnnC2BUEoDRcwXF8pq8XT1/3Hc3cuUJwX/otNe\nfr/Bomr3dtM0ERLN3DrepCXvuzEU5FcJVDUB3sI+pFtjjLBXD/zJmuL3Afg91J9p\n79+Dm+43cR6wuKywVJx5DJIdswF6oQDDzhwu89d2V5x02aXB9LqdXkPwiO0eR5s/\nxHXgASl+hqDdVL9hLod3iGa9nV7cElCbcl8UVXNPJnQAfaiKazF+hCdl/syrIh0K\nCZ5opggsTJibo8qFXBmG4PkT5YbhHE11wYKILwZFSvZ9iddRPQK3CtgFiBnXbVwU\n5t67tn9pMizHgypgsfBoeoyBrpTuc4egSCpjsQIDAQABAoIBAF2sU/wxvHbwAhQE\npnXVMMcO0thtOodxzBz3JM2xThhWnVDgxCPkAhWq2X0NSm5n9BY5ajwyxYH6heTc\np6lagtxaMONiNaE2W7TqxzMw696vhnYyL+kH2e9+owEoKucXz4QYatqsJIQPb2vM\n0h+DfFAgUvNgYNZ2b9NBsLn9oBImDfYueHyqpRGTdX5urEVtmQz029zaC+jFc7BK\nY6qBRSTwFwnVgE+Td8UgdrO3JQ/0Iwk/lkphnhls/BYvdNC5O8oEppozNVmMV8jm\n61K+agOh1KD8ky60iQFjo3VdFpUjI+W0+sYiYpDb4+Z9OLOTK/5J2EBAGim9siyd\ngHspx+UCgYEA9+t5Rs95hG9Q+6mXn95hYduPoxdFCIFhbGl6GBIGLyHUdD8vmgwP\ndHo7Y0hnK0NyXfue0iFBY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89d2V5x02aXB9LqdXkPwiO0eR5s/xHXgASl+hqDdVL9hLod3iGa9nV7cElCbcl8U\nVXNPJnQAfaiKazF+hCdl/syrIh0KCZ5opggsTJibo8qFXBmG4PkT5YbhHE11wYKI\nLwZFSvZ9iddRPQK3CtgFiBnXbVwU5t67tn9pMizHgypgsfBoeoyBrpTuc4egSCpj\nsQIDAQAB\n-----END PUBLIC KEY-----";
// With these self generated keys it doesn't work :(
var rsa = new RSAKey();
rsa.generate(512,"10001");
//pub_pem = rsa.publicKeyToX509PemString();
//priv_pem = rsa.privateKeyToPkcs1PemString();
var data = "hahahaah";
var encrypted;
// Encrypt it
Crypt.make(pub_pem, function (err, crypt)
{
crypt.encrypt(data, function (err, _encrypted)
{
console.log( _encrypted );
encrypted = _encrypted;
});
});
// Decrypt it
Crypt.make(priv_pem, function (err, crypt)
{
crypt.decrypt(encrypted, function (err, decrypted)
{
console.log( decrypted);
});
});
</script>
...
</html>

View File

@ -7,3 +7,10 @@
-file deletion or time to live (client side?) -file deletion or time to live (client side?)
# Cryptoshit
encrypt / decrypt:
http://www.davedoesdev.com/a-simple-and-consistent-wrapper-for-javascript-crypto/
generating keys:
https://bitbucket.org/adrianpasternak/js-rsa-pem/wiki/Home