Cryptography/CafeLib.Cryptography.UnitTests/BsvSharp/Passphrase/Mnemonic.cs
/// <summary>
/// The checksum is a substring of the binary representation of the SHA256 hash of entropy.
/// For every four bytes of entropy, one additional bit of the hash is used.
/// </summary>
/// <param name="entropy"></param>
/// <returns></returns>
The checksum is a substring of the binary representation of the SHA256 hash of entropy.
For every four bytes of entropy, one additional bit of the hash is used.
The checksum is a substring of the binary representation of the SHA256 hash of entropy . For every four bytes of entropy one additional bit of the hash is used .
private static string GetChecksum(ReadOnlyByteSequence entropy)
		{
			var hash = entropy.Sha256();
			var bits = (int)entropy.Length * 8;
			var cs = bits / 32;
			var sb = new StringBuilder();
			foreach (var b in hash.Span) 
			{
				sb.Append(Convert.ToString(b, 2).PadLeft(8, '0'));
				cs -= 8;
				if (cs <= 0) break;
			}
			if (cs < 0) sb.Length += cs;
			return sb.ToString();
		}
private static string GetChecksum ( ReadOnlyByteSequence entropy ) { var hash = entropy . Sha256 ( ) ; var bits = ( int ) entropy . Length * 8 ; var cs = bits / 32 ; var sb = new StringBuilder ( ) ; foreach ( var b in hash . Span ) { sb . Append ( Convert . ToString ( b , 2 ) . PadLeft ( 8 , ' ' ) ) ; cs -= 8 ; if ( cs <= 0 ) break ; } if ( cs < 0 ) sb . Length += cs ; return sb . ToString ( ) ; }
The checksum is a substring of the binary representation of the SHA256 hash of entropy.
The checksum is a substring of the binary representation of the SHA256 hash of entropy .
None
entropy
ReadOnlyByteSequence
None