mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			663 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			663 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
"use strict";
 | 
						|
 | 
						|
const options = require('./options');
 | 
						|
const scrypt = require('scrypt');
 | 
						|
 | 
						|
async function getVerificationHash(password) {
 | 
						|
    const salt = await options.getOption('password_verification_salt');
 | 
						|
 | 
						|
    return getScryptHash(password, salt);
 | 
						|
}
 | 
						|
 | 
						|
async function getPasswordDerivedKey(password) {
 | 
						|
    const salt = await options.getOption('password_derived_key_salt');
 | 
						|
 | 
						|
    return getScryptHash(password, salt);
 | 
						|
}
 | 
						|
 | 
						|
async function getScryptHash(password, salt) {
 | 
						|
    const hashed = scrypt.hashSync(password,
 | 
						|
        {N: 16384, r:8, p:1},
 | 
						|
        32,
 | 
						|
        salt);
 | 
						|
 | 
						|
    return hashed;
 | 
						|
}
 | 
						|
 | 
						|
module.exports = {
 | 
						|
    getVerificationHash,
 | 
						|
    getPasswordDerivedKey
 | 
						|
}; |