Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389519
D7761.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7761.diff
View Options
diff --git a/native/media/encryption-utils.js b/native/media/encryption-utils.js
--- a/native/media/encryption-utils.js
+++ b/native/media/encryption-utils.js
@@ -396,4 +396,26 @@
};
}
-export { encryptMedia, decryptMedia };
+function encryptBase64(
+ base64: string,
+ keyBytes?: Uint8Array,
+): { +base64: string, +keyHex: string } {
+ const rawData = commUtilsModule.base64DecodeBuffer(base64);
+ const aesKey = keyBytes ?? AES.generateKey();
+ const encrypted = AES.encrypt(aesKey, new Uint8Array(rawData));
+ return {
+ base64: commUtilsModule.base64EncodeBuffer(encrypted.buffer),
+ keyHex: uintArrayToHexString(aesKey),
+ };
+}
+
+function decryptBase64(encrypted: string, keyHex: string): string {
+ const encryptedData = commUtilsModule.base64DecodeBuffer(encrypted);
+ const decryptedData = AES.decrypt(
+ hexToUintArray(keyHex),
+ new Uint8Array(encryptedData),
+ );
+ return commUtilsModule.base64EncodeBuffer(decryptedData.buffer);
+}
+
+export { encryptMedia, decryptMedia, encryptBase64, decryptBase64 };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 7:27 PM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2602119
Default Alt Text
D7761.diff (1 KB)
Attached To
Mode
D7761: [native] Add utils to encrypt/decrypt base64 string
Attached
Detach File
Event Timeline
Log In to Comment