-
Notifications
You must be signed in to change notification settings - Fork 12
Description
On PHP for generate Hash (SHA-256).
I do next. But I do not know exactly is it correct. Please check me and correct if I am wrong.
Here is correct certificat (INI response is OK).
$cert = file_get_contents('files/cert.pem');
$cert_array = openssl_x509_parse($cert);
$cert_details = openssl_pkey_get_details(openssl_pkey_get_public($cert));
Exponent hash without leading zeros.
$exponent = ltrim(hash('sha256', base64_encode($cert_details['rsa']['e'])), '0');
Modulus hash without leading zeros.
$modulus = ltrim(hash('sha256', base64_encode($cert_details['rsa']['n'])), '0');
HEX representation.
$A006_unpack = unpack("H*", $exponent . ' ' . $modulus);
$A006_H = array_shift($A006_unpack);
Here is my Hash (SHA-256).
echo implode(' ', str_split(strtoupper($A006_H), 2));