On 04/10/15 1:09 AM, holo wrote:
On Saturday, 3 October 2015 at 05:02:58 UTC, Rikki Cattermole wrote:
On 03/10/15 6:01 PM, Rikki Cattermole wrote:
On 03/10/15 4:54 PM, holo wrote:
On Saturday, 3 October 2015 at 03:15:21 UTC, Rikki Cattermole wrote:
You could implement it yourself, (it looks pretty easy).
Or go the route of Botan:
https://github.com/etcimon/botan/blob/3bdc835d5b9bad7523deaa86fe98b1fbb2f09d6b/source/botan/mac/hmac.d
Thank you for answer. I used dub to fetch botan, after that i created
project:
dub init projectname botan
and tried to add botan module:
$ cat app.d
#!/usr/bin/rdmd
import std.stdio;
import botan.mac.hmac;
void main()
{
writeln("Edit source/app.d to start your project.");
}
but when im trying to run my simple app i get:
$ ./app.d
./app.d(4): Error: module hmac is in file 'botan/mac/hmac.d' which
cannot be read
import path[0] = .
import path[1] = /usr/include/dlang/dmd
Failed: ["dmd", "-v", "-o-", "./app.d", "-I."]
What am i doing wrong? How to add library with dub package manager? Im
really beginner in D (basically in programming) sorry if im asking
obvious questions.
By the looks of that error message with paths, botan isn't actually
added as a dependency. Can you please paste the dub file?
Ohhhh wait nevermind.
Use dub to compile/run your program. You are using the shebang line!
$ dub run
According to my other question are that functions equivalent to that
python one? If they are not doing exact that same i could not create
auth string which is needed to connect to AWS api.
I can't say for certain if it is not exact. The reason I did not answer
it is because I am not familiar with environment or any of what you are
doing.
I can unfortunately only point you in the right direction.
Thank you for explaining how to use dub.
I find out in master branch of phobos on git hub is included hmac.d
module which will be added in next release of phobos so i think that
will be best solution for me to stick with standard library for beginning.
https://github.com/D-Programming-Language/phobos/tree/master/std
I downloaded hmac.d and new version of digest.d file and place them in
my phobos library. I think it exactly contains what i need but when im
trying to test it i have such error:
$ ./app.d
./app.d(9): Error: template std.digest.hmac.hmac cannot deduce function
from argument types !(SHA!(512, 256))(immutable(ubyte)[]), candidates are:
/usr/include/dlang/dmd/std/digest/hmac.d(202): std.digest.hmac.hmac(H)
if (isDigest!H && hasBlockSize!H)
/usr/include/dlang/dmd/std/digest/hmac.d(208): std.digest.hmac.hmac(H,
ulong blockSize)(scope const(ubyte)[] secret) if (isDigest!H)
Failed: ["dmd", "-v", "-o-", "./app.d", "-I."]
My test code (based on unint test from module) looks like that:
#!/usr/bin/rdmd
import std.stdio;
import std.digest.sha, std.digest.hmac;
import std.string : representation;
void main()
{
auto hmac = hmac!SHA256("secretkey".representation);
auto digest = hmac.put("texttohash".representation).finish;
writeln(digest);
}
Am i using it correctly?
By the looks of things the problem is with SHA256, I'm guessing it
doesn't have its block size defined.
https://github.com/D-Programming-Language/phobos/blob/master/std/digest/digest.d#L394
You'll also need to update sha.d as well. Otherwise it looks good.