我有一个私钥和加密字符串。实际上,字符串已使用 .NET 模块加密。现在我需要解密字符串。我在 php 中尝试过,但它引发了以下错误
openssl_private_decrypt(): key parameter is not a valid private key
我在 perl 中尝试过,但它需要自己的私钥,但它需要使用我自己的私钥,该私钥已在我们的服务器中生成。
请建议我解决这个问题。PHP ,Ruby , Perl 解决方案会更有帮助。
$crypttext="gKL/n5hkBg4jyjrLRqjQbf9gAS3xnbp1xmCmamPO33fW21JAJtlVQHYR6O1dOw3tfobMe/0uXm/kgivae9zHNey4Wt3UGzPwosUrx7V8zhC97AXya2tuENO1Fmc4Z8l9+UalwtUZxMGtl3Ua9DYuvxLP/TuavgRNpmG6eemGPag=";
$fp=fopen("private.pem","r");
$priv_key=fread($fp,8192);
fclose($fp);
openssl_private_decrypt(base64_decode($crypttext ),$newsource,false ) ;
echo "String decrypt : $newsource"**;
私钥
<BitStrength>1024</BitStrength><RSAKeyValue><Modulus>t2G2WWIal1EinPn54ZPc3S1UgGTDxr6RFc+XEMR723VSg9toU8lSfTD7C26bUcbDxBwP1/1MbdQcx/dKX+7UlB5z79vrwfT89rUZGWeH7VZvuAawtHURgucyGMhqAZ9NxDEAl5Uo3nsNL9j1JlSBfeZf8pU5sf70KezqJTRsfrE=</Modulus><Exponent>AQAB</Exponent><P>82dZbOjQCJ7NV6EuVJXqPlh4FB65LBL1w9696sKFZuIr8refGwTZOY05se6oHbT9mn8OFXVA6A/wmz7oWNPk9w==</P><Q>wN8uixNk73DIF2SHb0aunnW5XxAIq3KxeQKoUTBAzL7BqXmKjk6XDnfxDbybmcT51wGhiO20lGg51zuxnsPXlw==</Q><DP>Kv4+VXZqCJvEOY5G2LoCPjDyRNuIabiPoKFfenARkDKzAJReji81D21am4tENrsZcIiwvCmR5WurXECoWchT0Q==</DP><DQ>qGRzW4O0VYVvfVUNFi9tF/aKwR/boe0CXDfgwvnRKbHGnfP67+JX6o73zFmGtQuQYpMO+OEpD4WsMmnw2z/7ww==</DQ><InverseQ>czq4+xiiVxb63ZtKwkxyJoDLFH0f18YlfFQTrEoAx7UE9HdjOjsJFpZ54g0yK3/S/yVgIXPwMcw6LU1QvqazPg==</InverseQ><D>Ktp/tWWSlzfToeFcvpVCMMGOFK73fTM9Tl6Di9yOoRtKnBuixqmuSCkxEVvYmgSb7PEt1qiPur6ttyEX1VFHhaugTr3aVhUpF+k7ULaHrCb8UymXXW3pp/yl/QOMPWuNKVv/GU3aQ3VTc3WUaYuOnaIkJk7uoYDQn0QqWtxtT60=</D></RSAKeyValue>