Ejemplo n.º 1
0
 /// <summary>Generate a SHA3 Hash/Key depend on password input as byte array.</summary>
 /// <remarks>Generate a SHA3 Hash/Key depend on password input as byte array.</remarks>
 /// <param name="keySize">Size of hash. Allowed are 224, 256, 384 and 512.</param>
 /// <param name="password">String password which will be hashed</param>
 /// <returns>SHA3 hash as byte array</returns>
 public virtual byte[] generateKeyByte(int keySize, string password)
 {
     byte[] bytePW = Encoding.UTF8.GetBytes(password);
     KeyGenSHA3.init(keySize);
     KeyGenSHA3.update(bytePW, bytePW.Length * 8);
     byte[] output = KeyGenSHA3.getHash();
     return(output);
 }
Ejemplo n.º 2
0
        /// <summary>Generate a SHA3 Hash/Key depend on password input as String.</summary>
        /// <remarks>Generate a SHA3 Hash/Key depend on password input as String.</remarks>
        /// <param name="keySize">Size of hash. Allowed are 224, 256, 384 and 512.</param>
        /// <param name="password">String password which will be hashed</param>
        /// <returns>SHA3 hash as Hex String</returns>
        public virtual string generateKey(int keySize, string password)
        {
            byte[] bytePW = Encoding.UTF8.GetBytes(password);
            KeyGenSHA3.init(keySize);
            KeyGenSHA3.update(bytePW, bytePW.Length * 8);
            string output = CryptobyHelper.bytesToHexString(KeyGenSHA3.getHash());

            return(output);
        }
Ejemplo n.º 3
0
        /// <summary>Generate a random SHA3 Hash/Key as byte array.</summary>
        /// <remarks>Generate a random SHA3 Hash/Key as byte array.</remarks>
        /// <param name="keySize">Size of hash. Allowed are 224, 256, 384 and 512.</param>
        /// <returns>SHA3 hash as byte array</returns>
        public virtual byte[] generateKeyByte(int keySize)
        {
            SecureRandom scRandom = new SecureRandom();

            byte[] randomPW = new byte[40];
            scRandom.nextBytes(randomPW);
            KeyGenSHA3.init(keySize);
            KeyGenSHA3.update(randomPW, randomPW.Length * 8);
            byte[] output = KeyGenSHA3.getHash();
            return(output);
        }
Ejemplo n.º 4
0
        /// <summary>Generate a random SHA3 Hash/Key as String.</summary>
        /// <remarks>Generate a random SHA3 Hash/Key as String.</remarks>
        /// <param name="keySize">Size of hash. Allowed are 224, 256, 384 and 512.</param>
        /// <returns>SHA3 hash as Hex String</returns>
        public virtual string generateKey(int keySize)
        {
            SecureRandom scRandom = new SecureRandom();

            byte[] randomPW = new byte[40];
            scRandom.nextBytes(randomPW);
            KeyGenSHA3.init(keySize);
            KeyGenSHA3.update(randomPW, randomPW.Length * 8);
            string output = CryptobyHelper.bytesToHexString(KeyGenSHA3.getHash());

            return(output);
        }