Example #1
0
        private static byte[] DecodeUserInput(string userInput, PgpWordList pgpWordList)
        {
            byte[] seed;
            if (Hexadecimal.TryDecode(userInput, out seed))
            {
                return(seed);
            }

            var splitInput = userInput.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            if (splitInput.Length == 1)
            {
                // Hex decoding failed, but it's not a multi-word mneumonic either.
                // Assume the user intended hex.
                throw new HexadecimalEncodingException();
            }
            return(pgpWordList.Decode(splitInput));
        }