AWS API Dlang, hmac sha256 function.
holo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Oct 2 20:11:04 PDT 2015
Hello
I'm trying to contact AWS API with D according to documentation:
http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
there is written example in python which i want to rewrite to D:
http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
I want to ask about such 2 things:
Is it equivalent in D:
hexDigest!SHA256("sometexttohash");
for such python method:
hashlib.sha256('sometexttohash').hexdigest()
?
Maybe is there some prettier solution in D eg:
toHexString(sha256Of("sometexttohash"));
or
SHA256 sha;
sha.start();
string data = "sometexttohash";
sha.put(data);
toHexString(sha.finish())
If those are equivalents to python method which should i choose?
Last but not least, how to write such function in D:
def sign(key, msg):
return hmac.new(key, msg.encode("utf-8"),
hashlib.sha256).digest()
?
I can't find in standard libraryt hmac function, is it existing?
//holo
More information about the Digitalmars-d-learn
mailing list