Ben Delphi koduna bu php dijital imzalama işlevini yeniden istiyoruz.
function SaySig() {
$privKeyFilePath = "c:\temp\myrsakey.pem";
$data = "sign this string";
$fp = fopen($privKeyFilePath, "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$privatekeyid = openssl_get_privatekey($priv_key);
openssl_sign($data, $signature, $privatekeyid, OPENSSL_ALGO_SHA1);
openssl_free_key($privatekeyid);
$sig = base64_encode($signature);
echo "<br>";
echo "Signature:".$sig."<br><br>";
}
Ben bileşeni kullanıldığı bakım (lockbox, DelphiOpenSSL, Chilkat Crypt ActiveX, vb) yok. Ben hiçbir başarı ile tüm bu denedim; bu bana temelden yanlış bir şey yapıyorum düşündürüyor.
Benim anahtar gibi oluşturulan:
openssl req-x509-düğümler-gün 365-NewKey rsa: 1024-sha1-subj "/ C = US / ST = CA / L = Mountain View / CN = www.mycompany.com"-keyout myrsakey.pem-out c: \ temp \ myrsacert.pem
Tuşunun içeriği (endişelenmeyin - Ben yeni bir tane oluşturur):
-----BEGIN RSA PRIVATE KEY----- MIICXgIBAAKBgQCqsR7s4X74LfTiLv1PP6Yn0SBpGBtbzkBSQ95E2b9Haa3Qtf0a KjDJpZLMwXC/IrSP7K2Gxbl2cZotT19GVgw6PcYPTBBWX2gJoVrnQZP8uPdlGAgS plODP55R9f4F0KzIpE6d+dpTGfJ1wysFqYN8fxtlu8K7YO/Mh8tNzN5VOQIDAQAB AoGBAIvCvRyeQlU5Y+JzMSvbZNQDUrNabsRL67SwJ2VemVUCvbQ/3v62fv4M2VdY KFYIN6oE08yfRw0pVWE2NT+lIxqSQx7+qv84Y7duqT7155wpCFj+a/6pYyNTFNFi 5wiTnN13eyHNgKxZm7QcMH67T/noTgz0LoT5p54ynmfNcjyBAkEA3DCEQ6Dm2xYH Nhk3+7sNEVklN20zNqyYvrCunNLAiLioF1jDApdfcT8YtVd29L7tH1ZdJYG5DXJ8 Bs7eKLGekQJBAMZzy0Q7LZHdWQxSRi7wy0eq6SqZMqi0pb9VPuXjWG1y+rtRr1vV vyMaGz4rcE7mkbq/Nkn+AQXc30GOj3GE8CkCQQCMDVwDfBN6pL8/fLjsJ+S+9RnD 8HRTwWKCX/UgkLif/fwEpZOcUVYGvSBlL9XdBJfkh9VFZwaidABJgEk0Tw3RAkBd 6pjMnpDvUeh9e0Y5mr0pGookHcIqsuspxEby9od3rI1aLsslU9+T1hwEbPxGarmW vj0MAUgspR2G4deiqn4ZAkEAnWxV7NhtVPLs5Y2ZYeHz7ipdcSL4/keLW4PwKerF 7LJj4s7/6ZqnHA6Z0yhCcziflYQArWt1ViLMIYZ8grr5Kg== -----END RSA PRIVATE KEY-----
Ve çıktı gibi görünüyor:
jcIIsr145dTwDrT8g4jb2HZ5FP5UL6/9mK7hF6hC2lCZGlM0W4QqFqytghWaU0w3Z6JkMVUlxxWtQ2R+ vWQVB0F3htAtbVZkiA67x0zor+zmpClBIazmfVJlng4sG1R7CCUZ0gGhdm4JMc08VsWU25utudcG6inpl whQiZgefW0=
It might appear as if I am requesting someone to "do my work". But I have been pounding away at this for some time with no success. Thanks.
Birisi benim kod bazı göndermek istedi. Aşağıda Ben denedim bazı şeyler vardır ..
function TMainWeb.sign(mstring: String): string;
var
mPrivateKey: TLbRSAKey;
LbRSASSA1: TLbRSASSA;
begin
LbRSASSA1:= TLbRSASSA.create(nil);
LbRSASSA1.PrivateKey.LoadFromFile('C:\temp\myrsakey.der');
LbRSASSA1.HashMethod := TRSAHashMethod(hmSHA1);
LbRSASSA1.SignString(mString);
result := LbRSASSA1.Signature.IntStr;
end;
function TMainWeb.sign1(mstring: String): string;
var
LbDSA1: TLbDSA;
mPrivateKey: TLbRSAKey;
begin
mPrivateKey := TLbRSAKey.Create(aks1024);
mPrivateKey.LoadFromFile('C:\temp\myrsakey.der');
LbDSA1 := TLbDSA.create(application);
lbDSA1.PrivateKey.Assign(mPrivateKey);
LbDSA1.SignString(mString);
end;
function TMainWeb.Sign2(mString: String): string;
var
signer: TMessageSigner;
begin
signer := TMessageSigner.Create;
signer.LoadPrivateKey('C:\temp\myrsakey.pem');
signer.PlainMessage := mString;
signer.MIMESign;
result := signer.SignedMessage;
end;