mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	use native node crypto for sha256
This commit is contained in:
		
							parent
							
								
									dd5a142fdd
								
							
						
					
					
						commit
						2533b8e121
					
				@ -2,7 +2,7 @@
 | 
			
		||||
 | 
			
		||||
const utils = require('./utils');
 | 
			
		||||
const aesjs = require('./aes');
 | 
			
		||||
const sha256 = require('./sha256');
 | 
			
		||||
const crypto = require('crypto');
 | 
			
		||||
 | 
			
		||||
function getProtectedSessionId(req) {
 | 
			
		||||
    return req.headers['x-protected-session-id'];
 | 
			
		||||
@ -12,15 +12,6 @@ function getDataAes(dataKey) {
 | 
			
		||||
    return new aesjs.ModeOfOperation.ctr(dataKey, new aesjs.Counter(5));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function arraysIdentical(a, b) {
 | 
			
		||||
    let i = a.length;
 | 
			
		||||
    if (i !== b.length) return false;
 | 
			
		||||
    while (i--) {
 | 
			
		||||
        if (a[i] !== b[i]) return false;
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function decrypt(dataKey, encryptedBase64) {
 | 
			
		||||
    if (!dataKey) {
 | 
			
		||||
        return "[protected]";
 | 
			
		||||
@ -64,9 +55,16 @@ function encrypt(dataKey, plainText) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function sha256Array(content) {
 | 
			
		||||
    const hash = sha256.create();
 | 
			
		||||
    hash.update(content);
 | 
			
		||||
    return hash.array();
 | 
			
		||||
    return crypto.createHash('sha256').update(content).digest();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function arraysIdentical(a, b) {
 | 
			
		||||
    let i = a.length;
 | 
			
		||||
    if (i !== b.length) return false;
 | 
			
		||||
    while (i--) {
 | 
			
		||||
        if (a[i] !== b[i]) return false;
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user