Exemplo n.º 1
0
    /// <summary>
    /// Computes the SHA1 hash from the given string.
    /// </summary>
    /// <param name="stringToHash">The string to hash.</param>
    /// <returns></returns>
    public static string GetSHA1Hash(string stringToHash)
    {
        var data     = Encoding.UTF8.GetBytes(stringToHash);
        var hashData = new SHA1CryptoServiceProvider().ComputeHash(data);

        return(String.Concat(hashData.Select(b => b.ToString("X2"))));
    }
Exemplo n.º 2
0
        private static void Other2(params string[] args)
        {
            var a = TimeSpan.FromSeconds(12345).ToString();
            var b = TimeSpan.FromSeconds(12390).ToString("hh\\:mm\\:ss");

            byte[] bytes1 = new SHA1CryptoServiceProvider().ComputeHash("input1".Select(x => (byte)x).ToArray());
            string hex1   = string.Join(string.Empty, bytes1.Select(x => string.Format("{0:x2}", x)));

            byte[] bytes2 = new SHA1CryptoServiceProvider().ComputeHash("input2".Select(x => (byte)x).ToArray());
            string hex2   = string.Join(string.Empty, bytes2.Select(x => string.Format("{0:x2}", x)));

            LineCounter.CountLines(args.First(), args.Skip(1).ToArray());

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey();
        }
Exemplo n.º 3
0
 public static string GenerateHash(string str)
 {
     byte[] hash = new SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(str));
     return(hash.Select(b => b.ToString("X2")).Aggregate((a, b) => (a + b)));
 }