mirror of https://github.com/waku-org/js-waku.git
Remove `Buffer` from `encrypt*`
This commit is contained in:
parent
5d32877357
commit
181ba489be
|
@ -118,10 +118,10 @@ export function clearDecode(
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export async function encryptAsymmetric(
|
export async function encryptAsymmetric(
|
||||||
data: Uint8Array | Buffer,
|
data: Uint8Array,
|
||||||
publicKey: Uint8Array | Buffer | string
|
publicKey: Uint8Array | string
|
||||||
): Promise<Uint8Array> {
|
): Promise<Uint8Array> {
|
||||||
return ecies.encrypt(Buffer.from(hexToBytes(publicKey)), Buffer.from(data));
|
return ecies.encrypt(hexToBytes(publicKey), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,18 +147,14 @@ export async function decryptAsymmetric(
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export async function encryptSymmetric(
|
export async function encryptSymmetric(
|
||||||
data: Uint8Array | Buffer,
|
data: Uint8Array,
|
||||||
key: Uint8Array | Buffer | string
|
key: Uint8Array | string
|
||||||
): Promise<Uint8Array> {
|
): Promise<Uint8Array> {
|
||||||
const iv = symmetric.generateIv();
|
const iv = symmetric.generateIv();
|
||||||
|
|
||||||
// Returns `cipher | tag`
|
// Returns `cipher | tag`
|
||||||
const cipher = await symmetric.encrypt(
|
const cipher = await symmetric.encrypt(iv, hexToBytes(key), data);
|
||||||
iv,
|
return concat([cipher, iv]);
|
||||||
Buffer.from(hexToBytes(key)),
|
|
||||||
Buffer.from(data)
|
|
||||||
);
|
|
||||||
return Buffer.concat([cipher, Buffer.from(iv)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue