mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
add b64 output encoding option for decrypt
This commit is contained in:
@@ -148,8 +148,7 @@ export class CryptoService implements CryptoServiceInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const privateKey = await this.decrypt(new CipherString(encPrivateKey), null, 'raw');
|
const privateKeyB64 = await this.decrypt(new CipherString(encPrivateKey), null, 'b64');
|
||||||
const privateKeyB64 = forge.util.encode64(privateKey);
|
|
||||||
this.privateKey = UtilsService.fromB64ToArray(privateKeyB64).buffer;
|
this.privateKey = UtilsService.fromB64ToArray(privateKeyB64).buffer;
|
||||||
return this.privateKey;
|
return this.privateKey;
|
||||||
}
|
}
|
||||||
@@ -327,8 +326,13 @@ export class CryptoService implements CryptoServiceInterface {
|
|||||||
|
|
||||||
if (outputEncoding === 'utf8') {
|
if (outputEncoding === 'utf8') {
|
||||||
return decipher.output.toString('utf8');
|
return decipher.output.toString('utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
const decipherBytes = decipher.output.getBytes();
|
||||||
|
if (outputEncoding === 'b64') {
|
||||||
|
return forge.util.encode64(decipherBytes);
|
||||||
} else {
|
} else {
|
||||||
return decipher.output.getBytes();
|
return decipherBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user