cast/bip38

1.0.1 2021-05-08 12:56 UTC

This package is auto-updated.

Last update: 2024-11-08 20:27:36 UTC


README

BIP-38

Install:

composer require cast/bip38

Usage:

<?php

use function Cast\Crypto\bip38\encrypt;
use function Cast\Crypto\bip38\decrypt;
use function Cast\BaseConv\base58EncodeCheck;
use function Cast\BaseConv\base58DecodeCheck;

$privateKey = '18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725';
$passphrase = 'TestingOneTwoThree';

$encrypted = encrypt($privateKey, $passphrase, '0142e0');
$encoded   = base58EncodeCheck(hex2bin($encrypted));
$decoded   = bin2hex(base58DecodeCheck($encoded));
$decrypted = decrypt($decoded, $passphrase);
$verified  = hash_equals($privateKey, $decrypted) ? 'true' : 'false'; // true

Links: