承接 xiaohuasheng0x1/bip39-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xiaohuasheng0x1/bip39-php

Composer 安装命令:

composer require xiaohuasheng0x1/bip39-php

包简介

BIP39 Mnemonics implementation in PHP

README 文档

README

Mnemonic BIP39 implementation in PHP

Installation

Prerequisite

  • PHP ^8.1
  • ext-mbstring (MultiByte string PHP ext. for non-english wordlist)

Composer

composer require xiaohuasheng0x1/bip39-php

Mnemonic Object

This lib will create this Mnemonic object as a result:

Prop Data Description
entropy string Hexadecimal representation of binary Entropy bits
wordsCount int Number of words (12, 15,18, 21 or 24)
wordsIndex array Indexed array (of integers) indexes from wordlist
words array Indexed array of mnemonic codes
rawBinaryChunks array Indexed array of binary bits (1s and 0s) each containing 11 bits according to BIP39 Spec

Generate Mnemonic Codes (12, 15, 18, 21 or 24 words)

Generate mnemonic of 12, 15, 18, 21 or 24 words using an entropy driven from cryptographically secure pseudo-random bytes.

<?php
declare(strict_types=1);

use \BIP\BIP39;

$mnemonic = BIP39::Generate(12);
var_dump($mnemonic->words);
# array(12) { [0]=> string(6) "barrel" [1]=> string(6) "viable" [2]=> string(6) "become" [3]=> string(4) "kiss" [4]=> string(6) "spider" [5]=> string(8) "business" [6]=> string(4) "wool" [7]=> string(6) "amused" [8]=> string(7) "satoshi" [9]=> string(4) "duty" [10]=> string(4) "girl" [11]=> string(5) "april" }
var_dump($mnemonic->entropy);
# string(32) "12de684fbd6d1a3e3f5041bf68918905" 

Generate Mnemonic using specified Entropy

Specify your own entropy to generate mnemonic codes:

<?php
declare(strict_types=1);

use \BIP\BIP39;

$mnemonic = BIP39::Entropy("f47f0e5dcf6d1ddf0e70791dafc9ae512130891817769976cd50533021e58a8b");
var_dump($mnemonic->wordsCount); # int(24) 
var_dump($mnemonic->words); # array(24) { [0]=> string(7) "virtual" [1]=> string(4) "wear" [2]=> stri...
var_dump($mnemonic->binaryChunks); # array(24) { [0]=> string(11) "11110100011" [1]=> string(11) "11111000011" [2]=> string(11) "10010...
var_dump($mnemonic->entropy); # string(64) "f47f0e5dcf6d1ddf0e70791dafc9ae512130891817769976cd50533021e58a8b"

Reverse (Mnemonic to Entropy)

Use mnemonic codes to find entropy. By default, lib will cross-check checksum therefore not using valid mnemonic codes will throw an exception.

<?php
declare(strict_types=1);

use \BIP\BIP39;

$mnemonic = BIP39::Words("virtual wear number paddle spike usage degree august buffalo layer high pelican basic duty gate uphold offer reopen favorite please acoustic version clay leader");
var_dump($mnemonic->entropy); # string(64) "f47f0e5dcf6d1ddf0e70791dafc9ae512130891817769976cd50533021e58a8b"

Generate non-english mnemonic codes

Mnemonic codes may be generated in ALL languages supported in BIP39 spec. This example generates 12 mnemonic codes in Spanish language as an example, and it may be replaced with other any other language with wordlists in BIP39 spec, check here.

<?php
declare(strict_types=1);

use \BIP\BIP39;
use \BIP\Wordlist;

$mnemonic = (new BIP39(12, Wordlist::Spanish())) // 12 words, Spanish language
    ->generateSecureMnemonic(); // Generate mnemonic
    
print implode(" ", $mnemonic->words); # bastón tímido turismo pez pez fideo pellejo persona brinco yoga rasgo diluir
print $mnemonic->entropy; # 1c9cfbc5d93b26b12bcd8c229fdb07a2

Test Vectors

  • [29-01-2023]: Test vectors mentioned in official BIP-0039 specification are tested and included in package. Execute tests/test_a.php to re-run following tests.

bip39-php

bip39-php

xiaohuasheng0x1/bip39-php 适用场景与选型建议

xiaohuasheng0x1/bip39-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mnemonics」 「bip39」 「BIP-0039」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 xiaohuasheng0x1/bip39-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xiaohuasheng0x1/bip39-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 xiaohuasheng0x1/bip39-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 41
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-24