Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33044917
D7761.1768417981.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7761.1768417981.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
Wed, Jan 14, 7:13 PM (2 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5933573
Default Alt Text
D7761.1768417981.diff (1 KB)
Attached To
Mode
D7761: [native] Add utils to encrypt/decrypt base64 string
Attached
Detach File
Event Timeline
Log In to Comment