Cryptography/CafeLib.Cryptography.UnitTests/BsvSharp/Passphrase/Mnemonic.cs
/// <summary>
/// Returns words converted into a binary string of "0" and "1" based on wordList.
/// If wordList is specified, then it is used.
/// Otherwise the wordList is selected based on the words provided.
/// If a wordList can't be determined, null is returned.
/// If a word is not found in wordList, null is returned.
/// </summary>
/// <param name="words">A sequence of space separated words from wordList, or one of the standard WordLists</param>
/// <param name="wordList">Optional wordList to be used.</param>
/// <returns>Returns words converted into a binary string of "0" and "1" based on wordList.</returns>
Returns words converted into a binary string of "0" and "1" based on wordList.
If wordList is specified, then it is used.
Otherwise the wordList is selected based on the words provided.
If a wordList can't be determined, null is returned.
If a word is not found in wordList, null is returned.
Returns words converted into a binary string of " 0 " and " 1 " based on wordList . If wordList is specified then it is used . Otherwise the wordList is selected based on the words provided . If a wordList can ' t be determined null is returned . If a word is not found in wordList null is returned .
public static string WordsToBinaryString(string words, string[] wordList = null)
		{
			words = words.Normalize(NormalizationForm.FormKD);
			wordList ??= GetWordList(words).wordList;
			if (wordList == null) return null;
			var bin = "";
			foreach (var w in words.Split(' ', StringSplitOptions.RemoveEmptyEntries)) {
				var i = Array.IndexOf(wordList, w);
				if (i < 0) return null;
				bin += Convert.ToString(i, 2).PadLeft(11, '0');
			}
			return bin;
		}
public static string WordsToBinaryString ( string words , string [ ] wordList = null ) { words = words . Normalize ( NormalizationForm . FormKD ) ; wordList ??= GetWordList ( words ) . wordList ; if ( wordList == null ) return null ; var bin = " " ; foreach ( var w in words . Split ( ' ' , StringSplitOptions . RemoveEmptyEntries ) ) { var i = Array . IndexOf ( wordList , w ) ; if ( i < 0 ) return null ; bin += Convert . ToString ( i , 2 ) . PadLeft ( 11 , ' ' ) ; } return bin ; }
Returns words converted into a binary string of "0" and "1" based on wordList.
Returns words converted into a binary string of " 0 " and " 1 " based on wordList .
Returns words converted into a binary string of "0" and "1" based on wordList.
Returns words converted into a binary string of " 0 " and " 1 " based on wordList .
words
string
A sequence of space separated words from wordList, or one of the standard WordLists
A sequence of space separated words from wordList or one of the standard WordLists
wordList
string[]
Optional wordList to be used.
Optional wordList to be used .