2015-03-30 98 views

回答

1

假設這在服務器上運行,您可以通過Npm.require('crypto')訪問crypto程序包。這裏有一個簡單的例子:

var crypto = Npm.require('crypto'); 
var text = 'hello world'; 
var key = 'abc123'; 

var hash = crypto.createHmac('sha512', key); 
hash.update(text); 
console.log(hash.digest('hex'));