-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied patch from Anonymous user (https://sourceforge.net/p/acryptoh…
- Loading branch information
1 parent
81cc436
commit f8a046b
Showing
3 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace Home.Andir.Cryptography.UnitTests | ||
{ | ||
[TestFixture] | ||
[Category("BlockAlgorithmTests")] | ||
public class BlockAlgorithmTests | ||
{ | ||
[Test] | ||
public static void BlockAlgorithmTest() | ||
{ | ||
byte[] b1 = Encoding.UTF8.GetBytes("hello"); | ||
byte[] b2 = Encoding.UTF8.GetBytes(" world"); | ||
|
||
HashAlgorithm sha1Managed = new SHA1Managed(); | ||
sha1Managed.TransformBlock(b1, 0, b1.Length, null, 0); | ||
var expected = | ||
sha1Managed.TransformFinalBlock(b2, 0, b2.Length); | ||
|
||
HashAlgorithm sha1 = new SHA1(); | ||
sha1.TransformBlock(b1, 0, b1.Length, null, 0); | ||
byte[] actual = | ||
sha1.TransformFinalBlock(b2, 0, b2.Length); | ||
|
||
if (expected.Length != actual.Length) | ||
{ | ||
Assert.Fail("Final block has wrong lengh"); | ||
} | ||
|
||
for (int ii = 0; ii < expected.Length; ii++) | ||
{ | ||
Assert.AreEqual(expected[ii], actual[ii], string.Format("Final block differ at {0} position", ii)); | ||
} | ||
} | ||
} | ||
} |
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