Skip to content
Browse files

Adding error if decryption fails

  • Loading branch information...
1 parent 189da04 commit 9562f89884dcbbaff126a7d02ca72b8ef1c9b44f @eoftedal committed Oct 1, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 PoetAndDidntKnowIt/Program.cs
View
5 PoetAndDidntKnowIt/Program.cs
@@ -81,9 +81,9 @@ private static byte[] DecryptBlock(byte[] encrypted, int blockNum, int padLength
var result = new byte[block.Length];
for (var i = 1; i <= block.Length; i++)
{
- var r = newIv[newIv.Length - i];
- byte lastByte = 0;
int curByte = newIv.Length - i;
+ var r = newIv[curByte];
+ int lastByte = -1;
for (var j = 255; j >= 0; j--)
{
newIv[curByte] = (byte)(r ^ j);
@@ -94,6 +94,7 @@ private static byte[] DecryptBlock(byte[] encrypted, int blockNum, int padLength
break;
}
}
+ if (lastByte == -1) throw new Exception("Could not decrypt this blocK");
result[curByte] = (byte)lastByte;
for (var k = 1; k <= i; k++)
{

0 comments on commit 9562f89

Please sign in to comment.
Something went wrong with that request. Please try again.