试试这个:
// Include library include('Crypt/RSA.php'); // Create an Instance $rsa = new Crypt_RSA(); //Get Private Key $privatekey = file_get_contents('C:\xampp\htdocs\encrypt\private.txt'); // Message to be signed $plaintext = "<Transaction><No>1344</No></Transaction>"; $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); // Set signing signature $encrypted = $rsa->sign($hashed); // Sign Data $signature = base64_encode($encrypted); // Encode to base64 the signed Data
PKCS1签名默认为sha1哈希值。您发布的代码实际上是sha1哈希的sha1哈希。