Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string transform  = "SHA-256";
            ulong  iterations = 65536;
            int    saltbytes  = 32;

            if( args.Length==0)
            {
                Console.WriteLine("Usage: hashgen.exe password [algorithm] [iterations] [salt-byte-size]");
                return;
            }
            string pwd = args[0];

            if( args.Length>1 )
                transform = args[1].ToUpper();
            if( args.Length>2 )
                iterations = ulong.Parse(args[2]);
            if( args.Length>3 )
                saltbytes = int.Parse(args[3]);

            HashManager hashman = new HashManager(transform, iterations);
            byte[] salt = HashManager.GenerateSalt(saltbytes);
            byte[] hash = hashman.Encode( pwd, salt );

            Console.WriteLine( "hash: " + HashManager.ConvertToHexString(hash) );
            Console.WriteLine( "salt: " + HashManager.ConvertToHexString(salt) );
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            string transform  = "SHA-256";
            ulong  iterations = 65536;
            int    saltbytes  = 32;

            if (args.Length == 0)
            {
                Console.WriteLine("Usage: hashgen.exe password [algorithm] [iterations] [salt-byte-size]");
                return;
            }
            string pwd = args[0];

            if (args.Length > 1)
            {
                transform = args[1].ToUpper();
            }
            if (args.Length > 2)
            {
                iterations = ulong.Parse(args[2]);
            }
            if (args.Length > 3)
            {
                saltbytes = int.Parse(args[3]);
            }

            HashManager hashman = new HashManager(transform, iterations);

            byte[] salt = HashManager.GenerateSalt(saltbytes);
            byte[] hash = hashman.Encode(pwd, salt);

            Console.WriteLine("hash: " + HashManager.ConvertToHexString(hash));
            Console.WriteLine("salt: " + HashManager.ConvertToHexString(salt));
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            string transform  = "SHA-256";
            ulong  iterations = 65536;

            if (args.Length < 3)
            {
                Console.WriteLine("Usage: pwdverify.exe password hash salt [algorithm] [iterations]");
                return;
            }
            string pwd  = args[0];
            string hash = args[1];
            string salt = args[2];

            if (args.Length > 3)
            {
                transform = args[3].ToUpper();
            }
            if (args.Length > 4)
            {
                iterations = ulong.Parse(args[4]);
            }

            HashManager hashman = new HashManager(transform, iterations);

            byte[] hashbuff = HashManager.ConvertFromHexString(hash);
            byte[] saltbuff = HashManager.ConvertFromHexString(salt);

            Console.WriteLine(hashman.Verify(pwd, hashbuff, saltbuff) ? "OK" : "INVALID PASSWORD");
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            string transform  = "SHA-256";
            ulong  iterations = 65536;

            if( args.Length<3)
            {
                Console.WriteLine("Usage: pwdverify.exe password hash salt [algorithm] [iterations]");
                return;
            }
            string pwd  = args[0];
            string hash = args[1];
            string salt = args[2];

            if( args.Length>3 )
                transform = args[3].ToUpper();
            if( args.Length>4 )
                iterations = ulong.Parse(args[4]);

            HashManager hashman = new HashManager(transform, iterations);
            byte[] hashbuff = HashManager.ConvertFromHexString(hash);
            byte[] saltbuff = HashManager.ConvertFromHexString(salt);

            Console.WriteLine( hashman.Verify( pwd, hashbuff, saltbuff ) ? "OK" : "INVALID PASSWORD" );
        }