Created
December 4, 2015 22:25
-
-
Save lukas2511/86907eceb6e69518947c to your computer and use it in GitHub Desktop.
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
use strict; | |
use Crypt::OpenSSL::RSA; | |
use Crypt::OpenSSL::Bignum; | |
use JSON; | |
use File::Slurp; | |
use MIME::Base64; | |
my $json_file = "private_key.json"; | |
my $json_content = read_file($json_file); | |
$json_content =~ tr/-/+/; | |
$json_content =~ tr/_/\//; | |
my $json = decode_json($json_content); | |
my $n = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{n})); | |
my $e = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{e})); | |
my $d = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{d})); | |
my $p = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{p})); | |
my $q = Crypt::OpenSSL::Bignum->new_from_bin(decode_base64($json->{q})); | |
my $rsa = Crypt::OpenSSL::RSA->new_key_from_parameters($n, $e, $d, $p, $q); | |
print($rsa->get_private_key_string()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment