How to use the scryptSync function from crypto
Find comprehensive JavaScript crypto.scryptSync code examples handpicked from public code repositorys.
GitHub: nwjs/node
204 205 206 207 208 209 210 211 212 213 214 215
crypto.DEFAULT_ENCODING = defaultEncoding; } for (const { args, expected } of badargs) { assert.throws(() => crypto.scrypt(...args), expected); assert.throws(() => crypto.scryptSync(...args), expected); } { const expected = { code: 'ERR_INVALID_ARG_TYPE' };
42
19
0
+ 21 other calls in file
GitHub: vulkanojs/vulkano
2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Encrypter { constructor(encryptionKey) { this.algorithm = 'aes-256-cbc'; this.key = crypto.scryptSync(encryptionKey, 'salt', 32); } encrypt(clearText) {
1
15
0
GitHub: possientis/Prog
12 13 14 15 16 17 18 19 20 21 22
function login(email, password) { const user = users.find(v => v.email === email); const [salt, key] = user.password.split(':'); const hashedBuffer = scryptSync(password, salt, 64); const keyBuffer = Buffer.from(key, 'hex'); const match = timingSafeEqual(hashedBuffer, keyBuffer);
0
3
0
+ 3 other calls in file
GitHub: brunmarg/popcare
103 104 105 106 107 108 109 110 111 112
} } encrypt(data) { const iv = crypto.randomBytes(16); const key = crypto.scryptSync(this.secret, iv, 32); const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); const encrypted = cipher.update(JSON.stringify(data), 'utf8', 'base64'); return iv.toString('base64') + '.' + encrypted + cipher.final('base64'); }
0
0
1
GitHub: Edge0410/DTPlan
30 31 32 33 34 35 36 37 38 39 40 41
}); app.post(["/login"], function(req, res){ console.log(req.body); var user = req.body.username; var password = crypto.scryptSync(req.body.password, "iewhrg3yYYDAjert377999", 32).toString('hex'); console.log(password); query = ` SELECT * FROM users
0
0
0
+ 3 other calls in file
57 58 59 60 61 62 63 64 65 66
encrypt: function(data, password, enc) { const config = require('../setup/config'); password = typeof password == 'string' ? password : config.secret; enc = typeof enc == 'string' ? enc : 'base64'; const iv = randomBytes(16); const key = scryptSync(password, iv, 32); const cipher = createCipheriv('aes-256-cbc', key, iv); const encrypted = cipher.update(data, 'utf8', enc); return iv.toString(enc) + '.' + encrypted + cipher.final(enc); },
0
0
0
+ 3 other calls in file
12 13 14 15 16 17 18 19 20 21 22 23
function login(email, password) { const user = users.find(v => v.email === email); const [salt, pw] = user.password.split(':'); // Make the hashedBuffer (not a hex string) because we need a buffer to use timingSafeEqual const hashedBuffer = scryptSync(password, salt, 64).toString('hex')// use the salt to make hash from the given password return hashedBuffer === pw; } const users = [];
0
0
0
+ 3 other calls in file
crypto.createHash is the most popular function in crypto (882 examples)