Created
May 17, 2018 10:32
-
-
Save m0freak/a51b587ad3945520fb16a33f3b23e21b to your computer and use it in GitHub Desktop.
Generate a data Signature using PHP and OPENSSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$priv_key = file_get_contents("./key.pem"); | |
$pkeyid = openssl_get_privatekey($priv_key); | |
$date_time="2016-06-01 12:00:00"; | |
$amount="1000"; | |
$narrative="Test transaction"; | |
$network_ref="1000100"; | |
$external_ref="ndhund-dkjndh-ldkjnd-ppolkiuj"; | |
$msisdn="256777000999"; | |
$data = $date_time . $amount . $narrative . $network_ref . $external_ref . $msisdn; | |
$signature = ""; | |
openssl_sign($data, $signature, $pkeyid); | |
openssl_free_key($pkeyid); | |
// Base64 RSA signature | |
$signature = base64_encode($signature); | |
echo $signature; | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment