public function testEncodeDecode() { $this->assertEquals(21, Hex::decode(Hex::encode(21))); $this->assertEquals(21212121, Hex::decode(Hex::encode(21212121))); $this->assertEquals('ABC', Hex::dataDecode(Hex::dataEncode('ABC'))); $this->assertEquals('hello world', Hex::dataDecode(Hex::dataEncode('hello world'))); }
public static function genSslKeyFingerprint($key) { $key = sslKeyPubClean($key); $keyBin = base64_decode($key); $keyBinSha512Bin = hash('sha512', $keyBin, true); $fingerprintHex = hash('ripemd160', $keyBinSha512Bin, false); $fingerprintBin = hash('ripemd160', $keyBinSha512Bin, true); $checksumHex = hash('sha512', hash('sha512', $fingerprintBin, true)); $checksumHex = substr($checksumHex, 0, 8); // 4 Bytes $num = Hex::decode($fingerprintHex . $checksumHex); #$numBase58 = Base58::encode($num); $base58 = new Base58(); $numBase58 = $base58->encode((string) $num); #$numBase58 = $base58->encode($num); $rv = 'FC_' . $numBase58; return $rv; }