publicKey2ipv6.php 323 B

123456789101112
  1. <?php
  2. require "base32.php";
  3. function publicKey2ipv6($publicKey)
  4. {
  5. $publicKey = preg_replace('#.k$#', '', $publicKey);
  6. $data = base32_decode($publicKey);
  7. $data = hash('sha512', $data, true);
  8. $data = hash('sha512', $data);
  9. $data = substr($data, 0, 32);
  10. return substr(preg_replace("#(.{4})#", "\$1:", $data), 0, -1);
  11. }