-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
64 lines (47 loc) · 2.07 KB
/
test.js
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
57
58
59
60
61
62
63
64
// var Crypto = require('crypto-js');
// // Crypto = Crypto.Crypto;
// // var key = 'this!smypa$$wordk3y'
// // console.log('program started');
// // var IV = '123456';
// // var MODE = new Crypto.mode.CFB(Crypto.pad.ZeroPadding);
// // var plaintext = 'The answer is no';
// // var input_bytes = Crypto.charenc.UTF8.stringToBytes(plaintext);
// // var key = Crypto.charenc.UTF8.stringToBytes(KEY);
// // var options = {iv: Crypto.charenc.UTF8.stringToBytes(IV), asBytes: true, mode: MODE};
// // var encrypted = Crypto.AES.encrypt(input_bytes, key, options);
// // var encrypted_hex = Crypto.util.bytesToHex(encrypted);
// // console.log(encrypted_hex); // this is the value you send over the wire
// // output_bytes = Crypto.util.hexToBytes(encrypted_hex);
// // output_plaintext_bytes = Crypto.AES.decrypt(output_bytes, key, options);
// // output_plaintext = Crypto.charenc.UTF8.bytesToString(output_plaintext_bytes);
// // console.log(output_plaintext); // result: 'The answer is no'
// var hash = Crypto.MD5("Message");
// console.log(hash.toString());
// var encrypted = Crypto.AES.encrypt("123456", "Secret Passphrase");
// console.log(encrypted.toString());
// //
// var decrypted = Crypto.AES.decrypt(encrypted, "Secret Passphrase");
// console.log(decrypted.toString());
// var salt = Crypto.lib.WordArray.random(128 / 8);
// var key128Bits = Crypto.PBKDF2("1234567", salt, {
// keySize: 128 / 32
// });
// console.log(key128Bits.toString())
// console.log()
// console.log()
// const bcrypt = require('bcrypt');
// const saltRounds = 3;
// const myPlaintextPassword = '123456';
// const someOtherPlaintextPassword = '1234561';
// // let hash;
// // bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
// // console.log(hash);
// // hash = hash;
// // });
// const hashX = bcrypt.hashSync(myPlaintextPassword, saltRounds);
// console.log(hashX);
// // bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) {
// // console.log(result)
// // });
// isAuthenticated = bcrypt.compareSync(someOtherPlaintextPassword, hashX)
// console.log(isAuthenticated);