Could you please help me on this error anybody its very urgnet issue in production.
i have an issue while doing the decription with ingrainkey value got below 2 errors.
1. Error in Decryption --> Invalid padding.
2. Error in Decryption --> Data size is not block size multiple.
why these two above errors got while doing decription with current key but same files encripted without
any errors and we are not able to download the files form UI side and got above two errors those file manualy able to opened.
Please help me what is the issue here from files or decription/encription/ code side while download the files.
i have an issue while doing the decription with ingrainkey value got below 2 errors.
1. Error in Decryption --> Invalid padding.
2. Error in Decryption --> Data size is not block size multiple.
About these error messages, if you could provide some main code, maybe it is helpful for someone to analysis your problems and give you some suggestions.
I find a similar thread and you could try to refer to it and hope it could helpful for you.
Member
30 Points
20 Posts
Error in Decryption --> Invalid padding and Data size is not block size multiple
Nov 03, 2014 07:09 AM|pulanarasima|LINK
Hi All,
Could you please help me on this error anybody its very urgnet issue in production.
i have an issue while doing the decription with ingrainkey value got below 2 errors.
1. Error in Decryption --> Invalid padding.
2. Error in Decryption --> Data size is not block size multiple.
why these two above errors got while doing decription with current key but same files encripted without
any errors and we are not able to download the files form UI side and got above two errors those file manualy able to opened.
Please help me what is the issue here from files or decription/encription/ code side while download the files.
Thansks in advance.
Regards,
Narasimha
asp.net
Narasimha
Contributor
6495 Points
1163 Posts
Re: Error in Decryption --> Invalid padding and Data size is not block size multiple
Nov 04, 2014 09:20 PM|Summer - MSFT|LINK
Hi pulanarasima,
Welcome to the ASP.NET forum.
About these error messages, if you could provide some main code, maybe it is helpful for someone to analysis your problems and give you some suggestions.
I find a similar thread and you could try to refer to it and hope it could helpful for you.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d1788582-bf8c-43ec-a686-49647c359136/unexplained-cryptographicexception-padding-is-invalid?forum=netfxbcl
Best Regards,
Summer
asp.net
Member
30 Points
20 Posts
Re: Error in Decryption --> Invalid padding and Data size is not block size multiple
Nov 18, 2014 06:18 AM|pulanarasima|LINK
Hi Summer,
Thanks for giving response and please find below code...decryption.Please help me on this .
FileStream fSource;
FileStream fDestination;
ICryptoTransform dec;
Byte[] inputChar = null;
Byte[] decryptedChar = null;
//Int64 bfrSize = 9999999;
int count;
int decryptedCount;
int dataSize = 150000;
string sourcePath = ConfigurationSettings.AppSettings["EncryptedBackUpFilesPath"] + fileName;
string destinationPath = ConfigurationSettings.AppSettings["DecryptedFiles"] + fileName;
fSource = File.OpenRead(sourcePath);
fDestination = File.Create(destinationPath);
inputChar = new Byte[dataSize + 16];
decryptedChar = new Byte[dataSize + 16];
dec = nKey.CreateDecryptor();
try
{
count = fSource.Read(inputChar, 0, dataSize);
while (count > 0)
{
decryptedCount = dec.TransformBlock(inputChar, 0, count, decryptedChar, 0);
fDestination.Write(decryptedChar, 0, decryptedCount);
count = fSource.Read(inputChar, 0, dataSize);
fDestination.Write(decryptedChar, 0, decryptedCount);
AesManaged aes = new AesManaged();
// aes.Padding = PaddingMode.None;
}
decryptedChar = dec.TransformFinalBlock(inputChar, 0, count); ---here getting the those two errors.
fDestination.Write(decryptedChar, 0, decryptedChar.Length);
Logger.LogError(destinationPath + " is decrypted. POMID is --> " + pomId);
//CryptoStream crStream = new CryptoStream(fDestination, nKey.CreateEncryptor(), CryptoStreamMode.Write);
//crStream.FlushFinalBlock();}
catch (NAEException ex)
{
Logger.LogError("Error in Decryption --> " + ex.Message);
}
finally
{
inputChar = null;
decryptedChar = null;
fSource.Flush();
fDestination.Flush();
fDestination.Close();
fSource.Close();
}
asp.net
Narasimha
Member
360 Points
109 Posts
Re: Error in Decryption --> Invalid padding and Data size is not block size multiple
Nov 21, 2014 03:55 AM|May-song|LINK
Hi
These code couldn't work? or have some error messages? please provide more information about your requirement?
May
asp.net