private static byte[] alternateSum(HashAlgorithm algorithm, byte[] password, byte[] salt) { algorithm.Initialize(); algorithm.AddToDigest(password); algorithm.AddToDigest(salt); algorithm.AddToDigest(password); return(algorithm.FinalizeAndGetHash()); }
public static void AddToDigestBuffered(this HashAlgorithm algorithm, byte[] inputBuffer, int inputOffset, int inputLength, int outputLength) { for (int i = 0; i < outputLength; i += inputLength) { algorithm.AddToDigest(inputBuffer, inputOffset, Math.Min(inputLength, outputLength - i)); } }
private static void intermediateCalc(HashAlgorithm algorithm, byte[] password, byte[] salt, byte[] intermediateSum, int i) { algorithm.Initialize(); if ((i & 1) != 0) { algorithm.AddToDigest(password); } else { algorithm.AddToDigest(intermediateSum); } if ((i % 3) != 0) { algorithm.AddToDigest(salt); } if ((i % 7) != 0) { algorithm.AddToDigest(password); } if ((i & 1) != 0) { algorithm.AddToDigest(intermediateSum); } else { algorithm.AddToDigest(password); } Array.ConstrainedCopy(algorithm.FinalizeAndGetHash(), 0, intermediateSum, 0, intermediateSum.Length); }
private static byte[] intermediateSum(HashAlgorithm algorithm, byte[] password, byte[] magic, byte[] salt, byte[] alternateSum) { algorithm.Initialize(); algorithm.AddToDigest(password); algorithm.AddToDigest(magic); algorithm.AddToDigest(salt); algorithm.AddToDigestBuffered(alternateSum, password.Length); byte[] temp = new byte[1]; for (int i = password.Length; i != 0; i >>= 1) { if ((i & 1) != 0) { temp[0] = 0; } else { temp[0] = password[0]; } algorithm.AddToDigest(temp); } return(algorithm.FinalizeAndGetHash()); }
public static void AddToDigest(this HashAlgorithm algorithm, byte[] block) { algorithm.AddToDigest(block, 0, block.Length); }