blob: 22e24321759b0704b84e9c1ecea2116766324084 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="forge/util.js"></script>
<script type="text/javascript" src="forge/sha256.js"></script>
<script type="text/javascript" src="forge/cipher.js"></script>
<script type="text/javascript" src="forge/cipherModes.js"></script>
<script type="text/javascript" src="forge/aes.js"></script>
<script type="text/javascript" src="forge/prng.js"></script>
<script type="text/javascript" src="forge/random.js"></script>
<script type="text/javascript" src="forge/jsbn.js"></script>
<script type="text/javascript" src="forge/asn1.js"></script>
<script type="text/javascript" src="forge/pem.js"></script>
<script type="text/javascript" src="forge/rsa.js"></script>
</head>
<body>
<script type="text/javascript">
function async() {
var bits = 2048;
console.log('Generating ' + bits + '-bit key-pair...');
var st = +new Date();
forge.pki.rsa.generateKeyPair({
bits: bits,
workers: -1,
/*workLoad: 100,*/
workerScript: 'forge/prime.worker.js'
}, function(err, keypair) {
var et = +new Date();
console.log('Key-pair created in ' + (et - st) + 'ms.');
//console.log('private', forge.pki.privateKeyToPem(keypair.privateKey));
//console.log('public', forge.pki.publicKeyToPem(keypair.publicKey));
});
}
function sync() {
var bits = 2048;
console.log('Generating ' + bits + '-bit key-pair...');
var st = +new Date();
var keypair = forge.pki.rsa.generateKeyPair(bits);
var et = +new Date();
console.log('Key-pair created in ' + (et - st) + 'ms.');
//console.log('private', forge.pki.privateKeyToPem(keypair.privateKey));
//console.log('public', forge.pki.publicKeyToPem(keypair.publicKey));
}
async();
//sync();
</script>
</body>
</html>
|