원격 웹 사이트에서 PHP 스크립트를 통해 자신을 인증해야하며 웹 사이트에서는 JS 기반 RSA 암호화를 사용하여 암호를 지정합니다. 다음 웹 사이트에서 코드는 다음과 같습니다JavaScript RSA 암호화 - PHP
function rsa_encrypt(strPlainText) {
var strModulus = "some_random_string";
var strExponent = "10001";
var rsa = new RSAKey();
rsa.setPublic(strModulus, strExponent);
var res = rsa.encrypt(strPlainText);
if (res) {
return res;
}
return false;
}
는이 웹 사이트에서 주제를 많이 탐색하고 권장되는 방법은 (다른 하나가 있다면 알려주세요) phpseclib를 사용하는 것으로 나타났습니다. 그러나 http://phpseclib.sourceforge.net/rsa/examples.html#encrypt,enc2의 기본 예제를 사용하면 빈 페이지가 나타납니다. some_random_string
을 $rsa->loadKey('...');
에 입력했습니다. 제대로했는지 확신 할 수 없습니까? 그러나이 예제에서는 strExponent
(10001)을 입력 할 수있는 곳을 볼 수 없습니다.
Fatal error: Call to a member function abs() on null in Math\BigInteger.php on line 1675
그러나
include('Crypt/RSA.php');
$privatekey = "some_random_string";
$rsa = new Crypt_RSA();
$rsa->loadKey($privatekey);
$plaintext = new Math_BigInteger('10001');
echo $rsa->_exponentiate($plaintext)->toBytes();
을,이 오류가 발생합니다 이 시간 동안 phpseclib 라이브러리에서 뭔가가 변경된 것 같아요. 코드를 다시 수정하는 방법을 모르겠습니다.