Created
September 30, 2015 00:54
-
-
Save sh1n0b1/35450bd07b7cbdfa5482 to your computer and use it in GitHub Desktop.
Decrypt strings encrypted by PKCS12 keys
This file contains 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 | |
$p12cert = array(); | |
$file = '[PATH]]'; | |
$c = file_get_contents($file); | |
if (openssl_pkcs12_read($c, $p12cert, '[REDACTED]') ) | |
{ | |
$pkey = $p12cert['pkey']; //private key | |
$cert = $p12cert['cert']; //public key | |
//decrypt the encrypted parameter value | |
$crypted = $argv[1]; | |
if(openssl_private_decrypt(base64_decode($crypted), $decrypted, $pkey)){ | |
echo $decrypted; | |
}else{ | |
echo 'failed to decrypt'; | |
} | |
} | |
else | |
{ | |
echo 'Failed read p12 file'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment