aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/test.js
blob: 91c0dc4ef0feca05050ef81b0fca874bd2623cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
load('jsbn.js')
load('jsbn2.js')
load('rsa.js')
load('rsa2.js')
//load random number generator
//TODO: plug-in sjcl random generator
load('prng4.js')
load('rng.js')
//next 2 scripts add a method to read an rsa key in the pem format
load('asn1hex.js')
load('rsa-pem.js')
load('base64.js')

key_string = read('key.pem')
key = new RSAKey()
key.readPrivateKeyFromPEMString(key_string)
cypher = key.encrypt("Guillaume est plus fort que Thibaut")
test = key.decrypt(cypher)

key2 = new RSAKey()
key2.generate(2048,"10001")