More managed code

simd-md5
Inga 🏳‍🌈 8 years ago
parent 6b8c2f56b6
commit 5d2c16668b
  1. 2
      dotnet/WhiteRabbit/MD5Digest.cs
  2. 8
      dotnet/WhiteRabbit/Phrase.cs

@ -12,7 +12,7 @@ namespace WhiteRabbit
internal static class MD5Digest internal static class MD5Digest
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe uint[] Compute(Phrase input) public static uint[] Compute(Phrase input)
{ {
uint a = 0x67452301; uint a = 0x67452301;
uint b = 0xefcdab89; uint b = 0xefcdab89;

@ -1,11 +1,11 @@
namespace WhiteRabbit namespace WhiteRabbit
{ {
// Anagram representation optimized for MD5 // Anagram representation optimized for MD5
internal unsafe struct Phrase internal class Phrase
{ {
public fixed uint Buffer[8]; public readonly uint[] Buffer = new uint[8];
public Phrase(byte[][] words, int numberOfCharacters) public unsafe Phrase(byte[][] words, int numberOfCharacters)
{ {
fixed (uint* bufferPointer = this.Buffer) fixed (uint* bufferPointer = this.Buffer)
{ {
@ -34,7 +34,7 @@
} }
} }
public byte[] GetBytes() public unsafe byte[] GetBytes()
{ {
fixed(uint* bufferPointer = this.Buffer) fixed(uint* bufferPointer = this.Buffer)
{ {

Loading…
Cancel
Save