PHP code example of cast / bip38

1. Go to this page and download the library: Download cast/bip38 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/ */

    

cast / bip38 example snippets


composer 



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