本文整理汇总了PHP中Crypt_RSA::createSign方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_RSA::createSign方法的具体用法?PHP Crypt_RSA::createSign怎么用?PHP Crypt_RSA::createSign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypt_RSA
的用法示例。
在下文中一共展示了Crypt_RSA::createSign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// create Crypt_RSA_KeyPair object
$key_pair = new Crypt_RSA_KeyPair(256, MATH_LIBRARY, 'check_error');
// check encrypting/decrypting function's behaviour
$params = array('enc_key' => $key_pair->getPublicKey(), 'dec_key' => $key_pair->getPrivateKey());
$rsa_obj->setParams($params);
$text = '1234567890';
$enc_text = $rsa_obj->encrypt($text);
$text1 = $rsa_obj->decrypt($enc_text);
if ($text != $text1) {
$errors[] = "error in encrypting/decrypting functions";
}
// check signing/sign validating
$params = array('public_key' => $key_pair->getPublicKey(), 'private_key' => $key_pair->getPrivateKey());
$rsa_obj->setParams($params);
$text = '1234567890';
$sign = $rsa_obj->createSign($text);
if (!$rsa_obj->validateSign($text, $sign)) {
$errors[] = "error in signing/sign validating functions with default hash function";
}
// check signing/sign validating with specific hash function
$params = array('hash_func' => create_function('$text', 'return 0x1234;'));
$rsa_obj->setParams($params);
$text = '1234567890';
$sign = $rsa_obj->createSign($text);
if (!$rsa_obj->validateSign($text, $sign)) {
$errors[] = "error in signing/sign validating functions with user specific hash function";
}
///////////////////////////////////////////////
// generate key with user-defined random generator.
///////////////////////////////////////////////
// use mt_rand function ( http://php.net/mt_rand ) as random generator