有一個函數crypto.pbkdf2Sync()
in node.js
API,我想在我的Angular2項目中使用它。Angular2:如何在node.js前端使用「crypto.pbkdf2Sync」功能
我試圖導入並使用它。項目編譯沒有錯誤,但在瀏覽器中我得到一個錯誤:
TypeError: webpack_require.i(...) is not a function at createHashSlow (hash.ts:4)
這裏是hash.ts
模塊:
import { pbkdf2Sync } from 'crypto';
import { CONFIG } from '../config';
export function createHashSlow(password, salt) {
return pbkdf2Sync(
password,
salt,
CONFIG.crypto.hash.iterations,
CONFIG.crypto.hash.length,
'SHA1'
).toString('base64');
};
我做了什麼錯?如何使它工作?
非常感謝! –