Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AS3 RSAKey.sign()!=PHP openssl_符号()_Php_Actionscript 3_Actionscript_Openssl_As3crypto - Fatal编程技术网

AS3 RSAKey.sign()!=PHP openssl_符号()

AS3 RSAKey.sign()!=PHP openssl_符号(),php,actionscript-3,actionscript,openssl,as3crypto,Php,Actionscript 3,Actionscript,Openssl,As3crypto,各位! 我有一些PHP代码来签署一些文本,它工作得很好。我需要在ActionScript3上有类似的代码。我需要你的帮助 $privateKeyPath = "private.key"; $message = "hello"; $privateKey = file_get_contents($privateKeyPath); openssl_sign($message, $signature, $privateKey); echo base64_encode($signature); 在AS

各位!

我有一些PHP代码来签署一些文本,它工作得很好。我需要在ActionScript3上有类似的代码。我需要你的帮助

$privateKeyPath = "private.key";
$message = "hello";
$privateKey = file_get_contents($privateKeyPath);
openssl_sign($message, $signature, $privateKey);

echo base64_encode($signature);
在AS3中,我使用as3crypto库进行标记:

private function readPrivateKey():String {
    var f:File = new File("/Users/ivan/Desktop/private.key");
    var fs:FileStream = new FileStream();
    fs.open(f,FileMode.READ);
    var key:String = fs.readUTFBytes(fs.bytesAvailable);
    fs.close();
    return key;
}

private function getSign():void {
    var message:String = "hello";
    var privateKey:String = readPrivateKey();
    var srcBA:ByteArray = new ByteArray();
    var resultBA:ByteArray = new ByteArray();
    var rsaKey:RSAKey;
    var base64encoder:Base64Encoder = new Base64Encoder();

    srcBA.writeUTFBytes(message);

    rsaKey = PEM.readRSAPrivateKey(privateKey);
    rsaKey.sign(srcBA, resultBA, srcBA.length);
    b64encoder.encodeBytes(resultBA);

    trace(b64encoder.toString());
}
我有相同的私钥文件。我希望输出值相等。但这些值是不同的=( 我做错了什么

更新:我尝试使用公钥和验证方法验证编码的base64字符串-Actionscript中的一切正常。 例如:

我的原始文本和解码值相等。因此,我得出结论,AS3签名方法不同于PHP。 有人有办法让它平等吗


谢谢。

也许回答晚了,但无论如何。。。 由于3在第二段代码中运行良好,PHP需要一些调整,如:

$privateKeyPath = "private.key";
$message = "hello";
$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyPath));
openssl_private_encrypt($message, $signature, $privateKey);

echo base64_encode($signature);
我刚刚用这个网站上的密钥进行了检查:
一切正常,我在PHP和AS3版本中都得到了类似的结果。

你好,谢尔盖夫·伊万,让我描述一下问题:openssl_sign()从数据创建摘要并加密有关摘要类型的信息,当您使用rsaKey.sign创建签名时,其默认加密功能是OPENSSL_algou_SHA1,因此两个签名都不同。谢谢您的评论。好的,我知道了,但我的任务仍然是实际的。我需要克隆OPENSSL_sign().是的,这是我在upwork上的帖子
$privateKeyPath = "private.key";
$message = "hello";
$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyPath));
openssl_private_encrypt($message, $signature, $privateKey);

echo base64_encode($signature);