Exemple #1
0
 public function testEncryptionUsingPrivateKeyBase64Encryption()
 {
     $rsa = new Zend_Crypt_Rsa(array('pemString' => $this->_testPemString));
     $encrypted = $rsa->encrypt('1234567890', $rsa->getPrivateKey(), Zend_Crypt_Rsa::BASE64);
     $this->assertEquals('1234567890', $rsa->decrypt($encrypted, $rsa->getPublicKey(), Zend_Crypt_Rsa::BASE64));
 }
<?php

$rsa = new Zend_Crypt_Rsa(array('passPhrase' => 'super segreto', 'pemPath' => APPLICATION_PATH . '/privatekey.pem'));
$testo = file_get_contents($filename);
$firma = $rsa->sign($testo, $rsa->getPrivateKey(), Zend_Crypt_Rsa::BASE64);
// Verifica la firma
$verify = $rsa->verifySignature($testo, $firma, Zend_Crypt_Rsa::BASE64);