CSharp examples for System.Security.Cryptography:SHA1
Hash SHA
/*//w w w . ja va 2 s . co m Commerce Starter Kit for EPiServer All rights reserved. See LICENSE.txt in project root. Copyright (C) 2013-2014 Oxx AS Copyright (C) 2013-2014 BV Network AS */ using System.Text; using System.Security.Cryptography; using System.Linq; using System.Globalization; using System.Collections.Generic; using System; public class Main{ private static byte[] HashSHA(byte[] innerKey, byte[] outerKey, byte[] message) { var hash = new SHA256Managed(); // Compute the hash for the inner data first byte[] innerData = new byte[innerKey.Length + message.Length]; Buffer.BlockCopy(innerKey, 0, innerData, 0, innerKey.Length); Buffer.BlockCopy(message, 0, innerData, innerKey.Length, message.Length); byte[] innerHash = hash.ComputeHash(innerData); // Compute the entire hash byte[] data = new byte[outerKey.Length + innerHash.Length]; Buffer.BlockCopy(outerKey, 0, data, 0, outerKey.Length); Buffer.BlockCopy(innerHash, 0, data, outerKey.Length, innerHash.Length); byte[] result = hash.ComputeHash(data); return result; } }