Last active
February 10, 2023 16:24
-
-
Save AvocadoVenom/71371b96c2c884fc0f04c476a78a3d15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import TextManipulationHelper from './text-manipulation'; | |
import CryptographyService from './cryptography.service'; | |
const decrypt = async (cipherText: string, secretKey: string, initialVector: string) => { | |
const keyBuffer = TextManipulationHelper.convertBase64ToStream(secretKey); | |
const decryptionKey = await CryptographyService.parseKey(keyBuffer); | |
const cipherBuffer = TextManipulationHelper.convertBase64ToStream(cipherText); | |
const ivBuffer = TextManipulationHelper.convertBase64ToStream<Uint8Array>(initialVector); | |
return await CryptographyService.decrypt(cipherBuffer, decryptionKey, ivBuffer) | |
}; | |
const cipher = 'base64-encrypted-content'; | |
const key = 'base64-encrpytion-key'; | |
const iv = 'base64-initial-vector'; | |
const plainText = decrypt(cipher, key, iv); | |
console.log(plainText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment