Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function getPublicKeyFingerprint(string $pemEncodedKey, string $hashAlgorithm = 'sha1')
  2. {
  3. $keyWithoutPemWrapper = preg_replace(
  4. '/^-----BEGIN (?:[A-Z]+ )?PUBLIC KEY-----([A-Za-z0-9\/\+\s=]+)-----END (?:[A-Z]+ )?PUBLIC KEY-----$/ms',
  5. '\1',
  6. $pemEncodedKey
  7. );
  8. $keyDataWithoutSpaces = preg_replace('/\s+/', '', $keyWithoutPemWrapper);
  9.  
  10. $binaryKey = base64_decode($keyDataWithoutSpaces);
  11.  
  12. return hash($hashAlgorithm, $binaryKey);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement