Frank1
1
I can do it by python as below:
import hmac
import hashlib
from urllib.parse import urlencode
secret_key = "sfsw............................esdfw2"
query_string = urlencode({"a": "a23a323", "b": "b23b45"}, True)
signature = hmac.new(secret_key.encode("utf-8"), query_string.encode("utf-8"), hashlib.sha256).hexdigest()
Now I want to do this by Rust, I want to get a simple demo;
Thanks!
I think this is equivalent:
Frank1
3
thanks for your reply;
The code prints as below:
[1D, 0E, E1, 45, AC, CA, 3E, FA, F2, CD, CE, 71, F2, 3F, FB, DC, C0, 99, 8D, AF, F5, 4D, 78, 55, E1, B3, F2, 76, 9E, 2C, 3D, BE]
Python code prints what looks like this:
'1d0ee145acca3efaf2cdce71f23ffbdcc0998daff54d7855e1b3f2769e2c3dbe'
Is this an implied question about formatting?
The bytes are the same as the output from your Python code - they're just formatted differently. If you output the bytes like this:
for b in &code_bytes {
print!("{:02x}", b);
}
println!();
you get exactly the same output as your original Python code.