Created
February 4, 2022 13:18
-
-
Save suchithm/a8790db1ecc780086be44ef20f2a6ef7 to your computer and use it in GitHub Desktop.
DoDecryption
This file contains hidden or 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
private void DoDecryption(string src, string dest) | |
{ | |
//iv = Base64.Decode(ivString , Base64Flags.NoWrap); | |
if (iv != null && iv.Length > 0) | |
{ | |
var secretKey = GetKeyFromKeyStore(); | |
Cipher cipher = Cipher.GetInstance("AES/GCM/NoPadding"); | |
Javax.Crypto.Spec.GCMParameterSpec spec = new Javax.Crypto.Spec.GCMParameterSpec(128, iv); | |
cipher.Init(Javax.Crypto.CipherMode.DecryptMode, secretKey, spec); | |
var bytes = System.IO.File.ReadAllBytes(src); | |
byte[] decodedData = cipher.DoFinal(bytes); | |
System.IO.File.WriteAllBytes(dest, decodedData); | |
if (System.IO.File.Exists(dest)) | |
{ | |
System.IO.File.Delete(src); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment