Example #1
0
        static void VerificarHash()
        {
            Console.WriteLine(MSG_CONST_HASH_COMPARE);
            string CompareHash = Console.ReadLine();

            Console.WriteLine(MSG_CONST_OPEN_FILE);
            string FileCompare = Console.ReadLine();

            if (FileCompare != "" && File.Exists(FileCompare))
            {
                var HashMD5    = BitConverter.ToString(Cryptograph.CalcularHashMD5(FileCompare)).Replace("-", "").ToLower();
                var HashSHA256 = BitConverter.ToString(Cryptograph.CalcularHashSHA256(FileCompare)).Replace("-", "").ToLower();

                if (string.Compare(CompareHash, HashMD5, StringComparison.InvariantCulture) == 0)
                {
                    Console.Write("\nMD5: True");
                }
                else
                {
                    Console.Write("\nMD5: False");
                }
                if (string.Compare(CompareHash, HashSHA256, StringComparison.InvariantCulture) == 0)
                {
                    Console.Write("\nSHA256: True");
                }
                else
                {
                    Console.Write("\nSHA256: False");
                }
            }
        }
Example #2
0
        static void SelectCryptograph(string type)
        {
            Console.WriteLine(MSG_CONST_OPEN_FILE);
            string PathFile = Console.ReadLine();

            if (PathFile != "" || PathFile != null)
            {
                if (File.Exists(PathFile))
                {
                    if (type == "1")
                    {
                        var Hash       = Cryptograph.CalcularHashMD5(PathFile);
                        var HashString = BitConverter.ToString(Hash).Replace("-", "").ToLower();
                        Console.WriteLine(MSG_CONST_HASH, "MD5", HashString);
                    }
                    else
                    {
                        var Hash       = Cryptograph.CalcularHashSHA256(PathFile);
                        var HashString = BitConverter.ToString(Hash).Replace("-", "").ToLower();
                        Console.WriteLine(MSG_CONST_HASH, "SHA256", HashString);
                    }
                }
                else
                {
                    Console.Write(MSG_CONST_FILE_NOT_EXIST, PathFile);
                }
            }
            else
            {
                Console.WriteLine(MSG_CONST_FILE_NULL);
            }
        }