用Montypay散列法求Flutter

tpxzln5u  于 2023-03-04  发布在  Flutter
关注(0)|答案(1)|浏览(94)

阅读完这个文档后,我坚持在某些字段“散列”如何生成它像想要的

String orderNumber = "order-1234";
      String orderAmount = "0.19";
      String orderCurrency = "usd";
      String orderDescription = "Important gift";
      String merchantPass = "merchantPass";
      final inputString =
          '$orderNumber$orderAmount$orderCurrency$orderDescription$merchantPass';
      final utf8Bytes = utf8.encode(inputString);
      final hash = md5.convert(utf8Bytes);
      final hashString = bytesToHex(hash.bytes).toUpperCase();

String bytesToHex(List<int> bytes) {
const hexDigits = '0123456789ABCDEF';
return bytes
    .map((byte) => hexDigits[(byte & 0xff) >> 4] + hexDigits[byte & 0x0f])
    .join('');

}
我试着把hashString放在hash字段中,但是每次响应都是

{
"error_code": 0,
"error_message": "Request data is invalid.",
"errors": [
    {
        "error_code": 100000,
        "error_message": "hash: Hash is not valid."
    }
]

}
这是 Postman 送的

此外,在集合中,有预先请求如何从中获取散列

有什么想法如何使它在应用程序?!

fcg9iug3

fcg9iug31#

它应该先升起来
示例来自他们的PHP文档:

示例:必须是MD5编码字符串的SHA1(大写):订单编号

  • 订单金额+订单币种+订单说明+密码

相关问题