sha256() public static méthode

Computes a digest hash value for the given data using the given method, and returns a raw or binhex encoded string, see: http://us1.php.net/manual/en/function.openssl-digest.php
public static sha256 ( string $data, $binary = false ) : string
$data string
Résultat string
Exemple #1
0
 public function testSha256()
 {
     $data = array(array('03d95e184cce34c3cfa58e9a277a09a7c5ed1b2a8134ea1e52887bc66fa3f47071', 'a5c756101065ac5b8f689139e6d856fa99e54b5000b6428b43729d334cc9277d'));
     foreach ($data as $datum) {
         $this->assertSame($datum[1], Util::sha256($datum[0]));
     }
 }
 /**
  * Generates a Service Identification Number (SIN), see:
  * https://en.bitcoin.it/wiki/Identity_protocol_v1
  *
  * @return SinKey
  * @throws \Exception
  */
 public function generate()
 {
     if (is_null($this->publicKey)) {
         throw new \Exception('Public Key has not been set');
     }
     $compressedValue = $this->publicKey;
     if (empty($compressedValue)) {
         throw new \Exception('The Public Key needs to be generated.');
     }
     $step1 = Util::sha256(Util::binConv($compressedValue), true);
     $step2 = Util::ripe160($step1);
     $step3 = sprintf('%s%s%s', self::SIN_VERSION, self::SIN_TYPE, $step2);
     $step4 = Util::twoSha256(Util::binConv($step3), true);
     $step5 = substr(bin2hex($step4), 0, 8);
     $step6 = $step3 . $step5;
     $this->value = Base58::encode($step6);
     return $this;
 }