Cryptography/CafeLib.Cryptography.UnitTests/BsvSharp/Passphrase/Mnemonic.cs
/// <summary>
/// Returns the entropy as a byte[] from a string of base 6 digits.
/// Verifies that there are at least length / Log2(6) rounded up digits in string.
/// This is 50 digits for 128 bits, 100 digits for 256 bits.
/// The string can use either digits 1-6, or 0-5.
/// This is implemented by treating 6 and 0 as the same value 0.
/// </summary>
/// <param name="base6">The string can use either digits 1-6, or 0-5.</param>
/// <param name="length">Optional entropy length in bits. Must be a multiple of 8.</param>
/// <returns>Returns the entropy as a byte[] from a string of base 6 digits.</returns>
Returns the entropy as a byte[] from a string of base 6 digits.
Verifies that there are at least length / Log2(6) rounded up digits in string.
This is 50 digits for 128 bits, 100 digits for 256 bits.
The string can use either digits 1-6, or 0-5.
This is implemented by treating 6 and 0 as the same value 0.
Returns the entropy as a byte [] from a string of base 6 digits . Verifies that there are at least length / Log2 ( 6 ) rounded up digits in string . This is 50 digits for 128 bits 100 digits for 256 bits . The string can use either digits 1 - 6 or 0 - 5 . This is implemented by treating 6 and 0 as the same value 0 .
private static byte[] Base6ToEntropy(string base6, int length = 128)
		{
			var needDigits = (int)Math.Ceiling(length / Math.Log(6, 2));
			if (base6.Length < needDigits)
				throw new ArgumentException($"For {length} bits of entropy, at least {needDigits} digits of base 6 are needed.");
			return BigIntegerToEntropy(Base6ToBigInteger(base6), length);
		}
private static byte [ ] Base6ToEntropy ( string base6 , int length = 128 ) { var needDigits = ( int ) Math . Ceiling ( length / Math . Log ( 6 , 2 ) ) ; if ( base6 . Length < needDigits ) throw new ArgumentException ( $" For  { length }  bits of entropy, at least  { needDigits }  digits of base 6 are needed. " ) ; return BigIntegerToEntropy ( Base6ToBigInteger ( base6 ) , length ) ; }
Returns the entropy as a byte[] from a string of base 6 digits.
Returns the entropy as a byte [] from a string of base 6 digits .
Returns the entropy as a byte[] from a string of base 6 digits.
Returns the entropy as a byte [] from a string of base 6 digits .
base6
string
The string can use either digits 1-6, or 0-5.
The string can use either digits 1 - 6 or 0 - 5 .
length
int
Optional entropy length in bits. Must be a multiple of 8.
Optional entropy length in bits . Must be a multiple of 8 .