MCPcopy Create free account
hub / github.com/Hattorius/CipherDrop / decryptFile

Function decryptFile

frontend/file.js:128–163  ·  view source on GitHub ↗
(encryptedData, encodedKey, encodedIv, mimeType, fileName)

Source from the content-addressed store, hash-verified

126}
127
128const decryptFile = async (encryptedData, encodedKey, encodedIv, mimeType, fileName) => {
129 const rawKey = base64UrlToArrayBuffer(encodedKey);
130 const iv = base64UrlToArrayBuffer(encodedIv);
131
132 const key = await crypto.subtle.importKey(
133 'raw',
134 rawKey,
135 {
136 name: 'AES-GCM',
137 length: 256
138 },
139 false,
140 [
141 "decrypt"
142 ]
143 );
144
145 const decryptedData = await crypto.subtle.decrypt(
146 {
147 name: 'AES-GCM',
148 iv
149 },
150 key,
151 encryptedData
152 );
153
154 return new File(
155 [
156 decryptedData
157 ],
158 fileName,
159 {
160 type: mimeType
161 }
162 );
163}

Callers 1

handleFileFunction · 0.85

Calls 1

base64UrlToArrayBufferFunction · 0.85

Tested by

no test coverage detected