我正在使用加密:验证它检查Google Play购买信息,是一个“坏参数例外”。我想让你知道如何。
OrderData = <<"{\"orderId\":\"12999763169054705758.1323507343902706\",\"packageName\":\"...\",\"productId\":\"item1\",\"purchaseTime\":1385090498734,\"purchaseState\":0,\"developerPayload\":\"DEVELOPER_PAYMENT\",\"purchaseToken\":\"...\"}">>),
PublicKeyString = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs4WYUM+LiABp/fp5YHngKjpCslKyhMIosBND3nbgFyrt2bv7Bd8nVl80kOWHPWR8HLUH5u+r8MP9KF7klG8OiWk1GROgs3pHB5BNl2TdOIT6rtnUJXslFqlnGh5IlpShJVUIrO2ADbXmwsN3AviZBw0ZjctfjK5t1UOvptSDGolBl5UtoVZ/TNjpa6QtMPtccGRDNmXAWFrEhTMDLdH+EPeapAmxi/rY0RBDMdobj1UtQdFA+iGlp6adbkjW7xFGWxyjS+dKFbn/jULxILfLVQ3XpGZXQMGW3FvyAvuZBM1ZWHrM4t0aQZGSHsvCste7hMe97lozsuXsb8JdfRjdO..."),
DataSignature = <<"MxauTspbl/1pB8836+sgM8Jw//auJ2VzIhV4JlxAHNJQ2klA20F8m2d/+60Px0MPCPhU478ezn4Jsy168RKjz+dTUjjwgN118uTO8aKjQ8DVwVNVR9FzljFSou2V9hY4TitzEyhl6Iy5B7GqReRsbd4b1YajLkuwRKIt4vSBlamqjVBBbgqGuq8ppRPp15wruRRMJdVHlZXXXmiDw1pd+nr7z9CXVZ0nAyivy9Tq8W1clKUmtHdQt3NtOR4kXiFfiu6+IOAedn1uwV2akfBTd5UD0/PbJeXy8sNWF/2yjzCGbn9HZJqGBG2R9HSehcolvhGI7mAwam8nt7ljkO0Gww==">>),
SizedBinary = fun(Binary) -> <<(size(Binary)):32/integer, Binary/binary>> end,
Hash = crypto:hash(sha, OrderData),
PublicKey = base64:decode(PublicKeyString), %% (is valid ???)
Signature1 = base64:decode(DataSignature), %% (is valid ???)
crypto:rsa_verify(SizedBinary(Hash), Signature1, PublicKey).
** exception error: bad argument
in function crypto:rsa_verify_nif/4
3条答案
按热度按时间g0czyy6m1#
fumotvh32#
验证代码。
f0ofjuux3#
您确定需要使用base64编解码器解码吗?因为根据文档:
AFAIK,应该使用verify/5。它是新API的一部分,不需要任何"mpint"值(带size标记的二进制文件)。