1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

rsa encrypt and decrypt tests

This commit is contained in:
Kyle Spearrin
2018-04-20 15:32:25 -04:00
parent 44f5d1c267
commit d73012efc8
5 changed files with 206 additions and 34 deletions

View File

@@ -39,6 +39,14 @@ export class Utils {
}
}
static fromByteStringToArray(str: string): Uint8Array {
const arr = new Uint8Array(str.length);
for (let i = 0; i < str.length; i++) {
arr[i] = str.charCodeAt(i);
}
return arr;
}
static fromBufferToB64(buffer: ArrayBuffer): string {
if (Utils.isNode) {
return new Buffer(buffer).toString('base64');
@@ -62,6 +70,10 @@ export class Utils {
}
}
static fromBufferToByteString(buffer: ArrayBuffer): string {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
}
// ref: https://stackoverflow.com/a/40031979/1090359
static fromBufferToHex(buffer: ArrayBuffer): string {
if (Utils.isNode) {