示例#1
0
        public static string GetKeyFromMachinCode(string machineCode)
        {
            Generate skgl = new Generate();

            //string machineCode = skgl.MachineCode.ToString();
            skgl.secretPhase = SimpleHash.ComputeHash(machineCode, HashStandards.MD5, Encoding.UTF8.GetBytes(machineCode));
            string key = skgl.doKey(0, Utility.Utility.GTSMinStandardDateTime, int.Parse(machineCode)).ToString();

            return(key);
        }
示例#2
0
        static void Main(string[] args)
        {
            string password      = "******"; // original password
            string wrongPassword = "******";   // wrong password

            string passwordHashMD5 =
                SimpleHash.ComputeHash(password, HashStandards.MD5, null);
            string passwordHashSha1 =
                SimpleHash.ComputeHash(password, HashStandards.SHA1, null);
            string passwordHashSha256 =
                SimpleHash.ComputeHash(password, HashStandards.SHA256, null);
            string passwordHashSha384 =
                SimpleHash.ComputeHash(password, HashStandards.SHA384, null);
            string passwordHashSha512 =
                SimpleHash.ComputeHash(password, HashStandards.SHA512, null);

            Console.WriteLine("COMPUTING HASH VALUES\r\n");
            Console.WriteLine("MD5   : {0}", passwordHashMD5);
            Console.WriteLine("SHA1  : {0}", passwordHashSha1);
            Console.WriteLine("SHA256: {0}", passwordHashSha256);
            Console.WriteLine("SHA384: {0}", passwordHashSha384);
            Console.WriteLine("SHA512: {0}", passwordHashSha512);
            Console.WriteLine("");

            Console.WriteLine("COMPARING PASSWORD HASHES\r\n");
            Console.WriteLine("MD5    (good): {0}",
                              SimpleHash.VerifyHash(
                                  password, HashStandards.MD5,
                                  passwordHashMD5).ToString());
            Console.WriteLine("MD5    (bad) : {0}",
                              SimpleHash.VerifyHash(
                                  wrongPassword, HashStandards.MD5,
                                  passwordHashMD5).ToString());
            Console.WriteLine("SHA1   (good): {0}",
                              SimpleHash.VerifyHash(
                                  password, HashStandards.SHA1,
                                  passwordHashSha1).ToString());
            Console.WriteLine("SHA1   (bad) : {0}",
                              SimpleHash.VerifyHash(
                                  wrongPassword, HashStandards.SHA1,
                                  passwordHashSha1).ToString());
            Console.WriteLine("SHA256 (good): {0}",
                              SimpleHash.VerifyHash(
                                  password, HashStandards.SHA256,
                                  passwordHashSha256).ToString());
            Console.WriteLine("SHA256 (bad) : {0}",
                              SimpleHash.VerifyHash(
                                  wrongPassword, HashStandards.SHA256,
                                  passwordHashSha256).ToString());
            Console.WriteLine("SHA384 (good): {0}",
                              SimpleHash.VerifyHash(
                                  password, HashStandards.SHA384,
                                  passwordHashSha384).ToString());
            Console.WriteLine("SHA384 (bad) : {0}",
                              SimpleHash.VerifyHash(
                                  wrongPassword, HashStandards.SHA384,
                                  passwordHashSha384).ToString());
            Console.WriteLine("SHA512 (good): {0}",
                              SimpleHash.VerifyHash(
                                  password, HashStandards.SHA512,
                                  passwordHashSha512).ToString());
            Console.WriteLine("SHA512 (bad) : {0}",
                              SimpleHash.VerifyHash(
                                  wrongPassword, HashStandards.SHA512,
                                  passwordHashSha512).ToString());
        }