Roel
11 years ago
4 changed files with 8086 additions and 0 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -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\ndHo7Y0hnK0NyXfue0iFBYD94/fuUe7GvcXib93heJlvPx9ykEZoq9DZnhPFBlg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+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> |
Loading…
Reference in new issue