mirror of
				https://github.com/therootcompany/keypairs.js.git
				synced 2024-11-16 17:29:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			16 lines
		
	
	
		
			355 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			355 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
var sha2 = module.exports;
 | 
						|
 | 
						|
var encoder = new TextEncoder();
 | 
						|
sha2.sum = function (alg, str) {
 | 
						|
	var data = str;
 | 
						|
	if ('string' === typeof data) {
 | 
						|
		data = encoder.encode(str);
 | 
						|
	}
 | 
						|
	var sha = 'SHA-' + String(alg).replace(/^sha-?/i, '');
 | 
						|
	return window.crypto.subtle.digest(sha, data).then(function (buf) {
 | 
						|
		return new Uint8Array(buf);
 | 
						|
	});
 | 
						|
};
 |