Bitpay\Util\Util::binConv PHP Метод

binConv() публичный статический Метод

Converts hex value into octet (byte) string
public static binConv ( $hex ) : string
Результат string
    public static function binConv($hex)
    {
        $rem = '';
        $dv = '';
        $byte = '';
        $digits = array();
        for ($x = 0; $x < 256; $x++) {
            $digits[$x] = chr($x);
        }
        if (substr(strtolower($hex), 0, 2) != '0x') {
            $hex = '0x' . strtolower($hex);
        }
        while (Math::cmp($hex, 0) > 0) {
            $dv = Math::div($hex, 256);
            $rem = Math::mod($hex, 256);
            $hex = $dv;
            $byte = $byte . $digits[$rem];
        }
        return strrev($byte);
    }

Usage Example

 /**
  * @inheritdoc
  */
 public function load($id)
 {
     if (!is_file($id)) {
         throw new \Exception(sprintf('Could not find "%s"', $id));
     }
     if (!is_readable($id)) {
         throw new \Exception(sprintf('"%s" cannot be read, check permissions', $id));
     }
     $encoded = file_get_contents($id);
     $decoded = openssl_decrypt(\Bitpay\Util\Util::binConv($encoded), self::METHOD, $this->password, 1, self::IV);
     if (false === $decoded) {
         throw new \Exception('Could not decode key');
     }
     return unserialize($decoded);
 }
All Usage Examples Of Bitpay\Util\Util::binConv