Assets/Scripts/Wallet/BouncyCastleHashing.cs
/// <summary>
/// Gets a PBKDF2_SHA256 Hash (CORE METHOD)
/// </summary>
/// <param name="password">The password as a plain text string</param>
/// <param name="salt">The salt as a byte array</param>
/// <param name="iterations">The number of times to encrypt the password</param>
/// <param name="hashByteSize">The byte size of the final hash</param>
/// <returns>A the hash as a byte array.</returns>
Gets a PBKDF2_SHA256 Hash (CORE METHOD)
Gets a PBKDF2_SHA256 Hash ( CORE METHOD )
public byte[] PBKDF2_SHA256_GetHash(string password, byte[] salt, int iterations, int hashByteSize)
    {
        var pdb = new Pkcs5S2ParametersGenerator(new Org.BouncyCastle.Crypto.Digests.Sha256Digest());
        pdb.Init(PbeParametersGenerator.Pkcs5PasswordToBytes(password.ToCharArray()), salt,
                     iterations);
        var key = (KeyParameter)pdb.GenerateDerivedMacParameters(hashByteSize * 8);
        return key.GetKey();
    }
public byte [ ] PBKDF2_SHA256_GetHash ( string password , byte [ ] salt , int iterations , int hashByteSize ) { var pdb = new Pkcs5S2ParametersGenerator ( new Org . BouncyCastle . Crypto . Digests . Sha256Digest ( ) ) ; pdb . Init ( PbeParametersGenerator . Pkcs5PasswordToBytes ( password . ToCharArray ( ) ) , salt , iterations ) ; var key = ( KeyParameter ) pdb . GenerateDerivedMacParameters ( hashByteSize * 8 ) ; return key . GetKey ( ) ; }
Gets a PBKDF2_SHA256 Hash (CORE METHOD)
Gets a PBKDF2_SHA256 Hash ( CORE METHOD )
A the hash as a byte array.
A the hash as a byte array .
password
string
The password as a plain text string
The password as a plain text string
salt
byte[]
The salt as a byte array
The salt as a byte array
iterations
int
The number of times to encrypt the password
The number of times to encrypt the password
hashByteSize
int
The byte size of the final hash
The byte size of the final hash