mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
implement crypto functions in more places
This commit is contained in:
@@ -26,6 +26,18 @@ export class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static fromHexToArray(str: string): Uint8Array {
|
||||
if (Utils.isNode) {
|
||||
return new Uint8Array(Buffer.from(str, 'hex'));
|
||||
} else {
|
||||
const bytes = new Uint8Array(str.length / 2);
|
||||
for (let i = 0; i < str.length; i += 2) {
|
||||
bytes[i / 2] = parseInt(str.substr(i, 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static fromUtf8ToArray(str: string): Uint8Array {
|
||||
if (Utils.isNode) {
|
||||
return new Uint8Array(Buffer.from(str, 'utf8'));
|
||||
|
||||
Reference in New Issue
Block a user