跳到主要内容

check_msg

  • 通过密钥与效验码效验报文

声明

public bool check_msg(string key, string msg, buffer valid_code)

参数

参数名描述
key长度在16-32之间的密钥
msg接需要效验的报文信息
valid_code经由 generate_hmac_sha1函数生成的效验码

返回值

返回效验是否成功,成功true,失败false

使用方式

import pkg.hmac_sha1;

string comm_msg = "abcdefg123456";
string key = hmac_sha1.create_secret_key();
buffer valid_code = hmac_sha1.generate_hmac_sha1(key, comm_msg);
write("Check should be true here :",hmac_sha1.check_msg(key, comm_msg,valid_code), "\n");

返回文档