<?php

/**
 * Copyright (c) 2014-2015 BitPay
 */
/**
 * This example show how to persist and load keys from the filesystem. Any key
 * can be persisted and loaded and the same way.
 */
require __DIR__ . '/../vendor/autoload.php';
// Create and generate
$pri = new \Bitpay\PrivateKey('/tmp/private.key');
$pri->generate();
// Use the key manager to persist key
$manager = new \Bitpay\KeyManager(new \Bitpay\Storage\EncryptedFilesystemStorage('password'));
// Saved to /tmp/private.key
$manager->persist($pri);
// Load from /tmp/private.key
$key = $manager->load('/tmp/private.key');
printf("Private Key: %s\n", $key);
Exemple #2
0
<?php

/**
 * Copyright (c) 2014-2015 BitPay
 */
require __DIR__ . '/../vendor/autoload.php';
/**
 * The first argument can either be the path to the key or can be
 * some other unique value. This is a basic example, and more advanced
 * examples can be used to store keys in the database or other places. In
 * this example, however, the keys are not persisted on disk or in a database.
 */
$private = new \Bitpay\PrivateKey('/tmp/private.key');
$public = new \Bitpay\PublicKey('/tmp/public.key');
$sin = new \Bitpay\SinKey('/tmp/sin.key');
// Generate Private Key values
$private->generate();
// Generate Public Key values
$public->setPrivateKey($private);
$public->generate();
// Generate Sin Key values
$sin->setPublicKey($public);
$sin->generate();
printf("Public Key:  %s\n", $public);
printf("Private Key: %s\n", $private);
printf("Sin Key:     %s\n\n", $sin);
$manager = new \Bitpay\KeyManager(new \Bitpay\Storage\EncryptedFilesystemStorage('dN$8WNaT}j<gD3*q'));
$manager->persist($private);
$manager->persist($public);