Package com.algorand.algosdk.mnemonic
Class Mnemonic
- java.lang.Object
-
- com.algorand.algosdk.mnemonic.Mnemonic
-
public class Mnemonic extends Object
Provides an easy way to create mnemonics from 32-byte length keys.
-
-
Constructor Summary
Constructors Constructor Description Mnemonic()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
checksum(byte[] data)
static String
fromKey(byte[] key)
Converts a 32-byte key into a 25 word mnemonic.static byte[]
toKey(String mnemonicStr)
toKey converts a mnemonic generated using this library into the source key used to create it.
-
-
-
Method Detail
-
fromKey
public static String fromKey(byte[] key)
Converts a 32-byte key into a 25 word mnemonic. The generated mnemonic includes a checksum. Each word in the mnemonic represents 11 bits of data, and the last 11 bits are reserved for the checksum.- Parameters:
key
- 32 byte length key- Returns:
-
toKey
public static byte[] toKey(String mnemonicStr) throws GeneralSecurityException
toKey converts a mnemonic generated using this library into the source key used to create it. It returns an error if the passed mnemonic has an incorrect checksum, if the number of words is unexpected, or if one of the passed words is not found in the words list.- Parameters:
mnemonicStr
- words delimited by MNEMONIC_DELIM- Returns:
- 32 byte array key
- Throws:
GeneralSecurityException
-
checksum
protected static String checksum(byte[] data)
-
-