WordsUtils class

The WordsUtils class is a utility class written in Dart that provides various functions: static Future<List

Constructors

WordsUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

generateWords() Future<List<String>>
A static method named generateWords that generates a list of random words using a pre-defined dictionary of words. The method initializes an empty list newList to store the generated words. It also defines a random variable that uses the Random.secure() method to generate cryptographically secure random numbers. The method uses a for loop to generate CryptoMisc.wordsLength - 2 random words from the wordsDictionary array and add them to newList. The method concatenates all the generated words into a single string variable named concat. The method uses the pwHash() method from the CryptoMisc class to generate a password hash from the concat string, along with a pre-defined salt and iteration count. The method converts the resulting password hash to a BigInt value, calculates the remainder of the hash modulo the length of the wordsDictionary array, and assigns the result to an integer variable named index. The method adds the word at the index position of the wordsDictionary array to newList, and appends it to concat. The method repeats steps 4-6 to generate another password hash from the updated concat string, and uses the hash to calculate the index of the final word to add to newList. The method adds the final word at the calculated index to newList and returns the resulting list of words.
startWordsChallenge(int iterations, List<String> wordList) Map<int, String>
This method starts a word challenge by randomly selecting a certain number of words from a given wordList. It takes two arguments: iterations specifies the number of words to be selected, and wordList is a list of strings containing the available words. Checks if iterations is greater than CryptoMisc.wordsLength (assuming CryptoMisc.wordsLength is defined elsewhere). If so, it throws an error indicating that the challenge cannot be lengthier than the wordlist. Initializes an empty list indexTestedWords to keep track of the selected word indices. Initializes an empty map wordsToBeTested to store the selected words with their respective indices. Iterates iterations times and performs the following steps: Generates a random index using the _generateRandomInt() helper method, ensuring it falls within the range of valid indices in the wordList. Checks if the generated index has already been used. If so, generates a new index until a unique one is found. Adds the unique index and the corresponding word from wordList to the wordsToBeTested map. Adds the used index to the indexTestedWords list. Returns the wordsToBeTested map containing the selected words and their indices.