PHPackages                             sakoora0x/bip39-mnemonic-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sakoora0x/bip39-mnemonic-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sakoora0x/bip39-mnemonic-php
============================

BIP39 Mnemonics implementation in PHP

v1.0.0(6mo ago)066MITPHP

Since Oct 24Pushed 6mo agoCompare

[ Source](https://github.com/sakoora0x/bip39-mnemonic-php)[ Packagist](https://packagist.org/packages/sakoora0x/bip39-mnemonic-php)[ RSS](/packages/sakoora0x-bip39-mnemonic-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

BIP39 Mnemonic
==============

[](#bip39-mnemonic)

Mnemonic BIP39 implementation in PHP

Installation
------------

[](#installation)

### Prerequisite

[](#prerequisite)

- PHP ^8.2
- [ext-mbstring](http://php.net/manual/en/book.mbstring.php) (MultiByte string PHP ext. for non-english wordlist)

### Composer

[](#composer)

`composer require sakoora0x/bip39-mnemonic-php`

Generating a Secure Mnemonic
----------------------------

[](#generating-a-secure-mnemonic)

Generate a mnemonic using a secure PRNG implementation.

### `BIP39::fromRandom`

[](#bip39fromrandom)

ArgumentTypeDescription$wordList`AbstractLanguage`Langage instance for wordlist$wordCountintNumber of words (12-24)**Returns instance of [Mnemonic](#mnemonic-class) class.**

#### Example:

[](#example)

```
// Generate entropy using PRNG
$mnemonic = \sakoora0x\BIP39\BIP39::fromRandom(
    \sakoora0x\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);

```

Entropy to Mnemonic
-------------------

[](#entropy-to-mnemonic)

Generate mnemonic codes from given entropy

### `BIP39::fromEntropy`

[](#bip39fromentropy)

ArgumentTypeDescription$entropy`string`Raw binary entropy bytes$wordList`AbstractLanguage`Langage instance for wordlist**Returns instance of [Mnemonic](#mnemonic-class) class.**

#### Example:

[](#example-1)

```
$mnemonic = \sakoora0x\BIP39\BIP39::fromEntropy(
    hex2bin("ddd9dbcd1b07a09c16f080637818675f"),
    \sakoora0x\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 sentence/Words to Mnemonic
-----------------------------------

[](#mnemonic-sentencewords-to-mnemonic)

Generate entropy from mnemonic codes

### `BIP39::fromWords`

[](#bip39fromwords)

ArgumentTypeDescription$wordsArray&lt;string&gt;Array of mnemonic codes$wordList`AbstractLanguage`Langage instance for wordlist$verifyChecksumboolDefaults to `TRUE`, computes and verifies checksum as per BIP39 spec.**Returns instance of [Mnemonic](#mnemonic-class) class.**

#### Example:

[](#example-2)

```
$mnemonic = \sakoora0x\BIP39\BIP39::fromWords(
    ["tape", "solution", "viable", "current", "key",
        "evoke", "forward", "avoid", "gloom", "school", "border", "sample"],
    \sakoora0x\BIP39\Language\English::getInstance()
);

#string(32) "ddd9dbcd1b07a09c16f080637818675f"
var_dump($mnemonic->entropy);

```

Mnemonic Class
--------------

[](#mnemonic-class)

### `readonly class` Mnemonic

[](#readonly-class--mnemonic)

This lib will create this Mnemonic object as a result:

PropertyTypeDescriptionlanguagestringLanguage name (as it was passed to constructor of wordlist class)wordsArray&lt;string&gt;Mnemonic codeswordsIndexArray&lt;int&gt;Position/index # of each mnemonic code corresponding to wordlist usedwordsCountintNumber of mnemonic codes (i.e. 12, 15, 18, 21 or 24)entropystringEntropy in hexadecimal encoding### Generating Seed with Passphrase

[](#generating-seed-with-passphrase)

#### `Mnemonic->generateSeed`

[](#mnemonic-generateseed)

Generates seed from a mnemonic as per BIP39 specifications.

ArgumentTypeDescription$passphrasestringDefaults to empty string ("")$bytesintNumber of bytes to return, defaults to 64.**Returns**:

TypeDescriptionstringReturns computed PBKDF2 hash in RAW BINARY as stringGenerate non-english mnemonic codes
-----------------------------------

[](#generate-non-english-mnemonic-codes)

Check `AbstractLanguage` and `AbstractLanguageFile` classes. [English](src/Language/English.php) class has all 2048 words pre-loaded instead of reading from a local file every time. To implement other languages or custom set of 2048 words, check [ChineseWords.php](tests/ChineseWords.php) file in `tests` directory for example of implementation.

```
class CustomWords extends \sakoora0x\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"
        );
    }
}

```

and then use in place of `AbstractLanguage` where required:

```
CustomWords::getInstance()

```

Test Vectors
------------

[](#test-vectors)

Include PHPUnit tests for all test vectors mentioned in [official BIP-0039 specification](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#user-content-Test_vectors).

### Running Tests

[](#running-tests)

Install dependencies:

```
composer install

```

Run tests:

```
./vendor/bin/phpunit

```

Run tests with verbose output:

```
./vendor/bin/phpunit --testdox

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance66

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a57bfb0b7a98c2728ab3b8e2d9e41a18bd0f9d47fccefbd3ebc6d1293801f94?d=identicon)[sakoora0x](/maintainers/sakoora0x)

---

Top Contributors

[![sakoora0x](https://avatars.githubusercontent.com/u/239889939?v=4)](https://github.com/sakoora0x "sakoora0x (1 commits)")

---

Tags

mnemonicsbip39BIP-0039

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sakoora0x-bip39-mnemonic-php/health.svg)

```
[![Health](https://phpackages.com/badges/sakoora0x-bip39-mnemonic-php/health.svg)](https://phpackages.com/packages/sakoora0x-bip39-mnemonic-php)
```

###  Alternatives

[furqansiddiqui/bip39-mnemonic-php

BIP39 Mnemonics implementation in PHP

56176.9k18](/packages/furqansiddiqui-bip39-mnemonic-php)[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.5k74.6k86](/packages/pocketmine-pocketmine-mp)[godruoyi/php-snowflake

An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).

8582.3M61](/packages/godruoyi-php-snowflake)[bitwasp/bitcoin

PHP Bitcoin library with functions for transactions, signatures, serialization, Random/Deterministic ECDSA keys, blocks, RPC bindings

1.1k533.2k43](/packages/bitwasp-bitcoin)[bitwasp/buffertools

Toolbox for working with binary and hex data. Similar to NodeJS Buffer.

65764.4k41](/packages/bitwasp-buffertools)[pocketmine/math

PHP library containing math related code used in PocketMine-MP

45573.2k14](/packages/pocketmine-math)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
