PHP code example of furqansiddiqui / bip39-mnemonic-php
1. Go to this page and download the library: Download furqansiddiqui/bip39-mnemonic-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
furqansiddiqui / bip39-mnemonic-php example snippets
// Generate entropy using PRNG
$mnemonic = \FurqanSiddiqui\BIP39\BIP39::fromRandom(
\FurqanSiddiqui\BIP39\Language\English::getInstance(),
wordCount: 12
);
# array(12) { [0]=> string(4) "tape" [1]=> string(8) "solution" ... [10]=> string(6) "border" [11]=> string(6) "sample" }
var_dump($mnemonic->words);
# string(32) "ddd9dbcd1b07a09c16f080637818675f"
var_dump($mnemonic->entropy);
$mnemonic = \FurqanSiddiqui\BIP39\BIP39::fromEntropy(
\Charcoal\Buffers\Buffer::fromBase16("ddd9dbcd1b07a09c16f080637818675f"),
\FurqanSiddiqui\BIP39\Language\English::getInstance()
);
# array(12) { [0]=> string(4) "tape" [1]=> string(8) "solution" ... [10]=> string(6) "border" [11]=> string(6) "sample" }
var_dump($mnemonic->words);
$mnemonic = \FurqanSiddiqui\BIP39\BIP39::fromWords(
["tape", "solution", "viable", "current", "key",
"evoke", "forward", "avoid", "gloom", "school", "border", "sample"],
\FurqanSiddiqui\BIP39\Language\English::getInstance()
);
#string(32) "ddd9dbcd1b07a09c16f080637818675f"
var_dump($mnemonic->entropy);
class CustomWords extends \FurqanSiddiqui\BIP39\Language\AbstractLanguageFile
{
/**
* @return static
*/
protected static function constructor(): static
{
return new static(
language: "some_language",
words: static::wordsFromFile(
pathToFile: "/path/to/wordlist.txt",
eolChar: PHP_EOL
),
mbEncoding: "UTF-8"
);
}
}
CustomWords::getInstance()
phpunit.phar --bootstrap vendor/autoload.php tests/