mirror of
https://github.com/status-im/dappconnect-sdks.git
synced 2025-02-10 23:56:25 +00:00
* add pbkdf2 browser implementation * use webcrypto in pbkdf2 * rename pbkdf2 file * use pbkdf2 * add changeset * revert rename * remove browser field from package.json * use `resolve.alias` for pbkdf2 if test * use `mode` in vite.config.ts Co-authored-by: Felicio Mununga <felicio@users.noreply.github.com>
21 lines
485 B
TypeScript
21 lines
485 B
TypeScript
import { utf8ToBytes } from 'ethereum-cryptography/utils'
|
|
|
|
import { pbkdf2 } from '../crypto/pbkdf2.browser'
|
|
|
|
const AES_KEY_LENGTH = 32 // bytes
|
|
|
|
/**
|
|
* status-go: https://github.com/status-im/status-go/blob/a471fed6a64e01a1aba8d925377fba045a5aa9f9/wakuv2/waku.go#L713
|
|
*/
|
|
export async function generateKeyFromPassword(
|
|
password: string
|
|
): Promise<Uint8Array> {
|
|
return await pbkdf2(
|
|
utf8ToBytes(password),
|
|
utf8ToBytes(''),
|
|
65356,
|
|
AES_KEY_LENGTH,
|
|
'sha256'
|
|
)
|
|
}
|