Re: SHA256 Signature
On Tuesday, 18 June 2024 at 17:18:18 UTC, Erdem wrote: On Tuesday, 18 June 2024 at 06:49:24 UTC, Vahid wrote: How can I create a SHA256 signature hash in D? Does this do what you want? ```d import std.digest.md; import std.digest.sha; import std.stdio; void main() { auto key = makeDigest!SHA256(); key.put(cast(ubyte[])"çorba"); auto result = key.finish(); writeln(result.toHexString()); } ``` Thank you for your reply. I have found that the issue is related to the 'Secret' variable. In fact, I possess a private key that needs to sign it for the JWT. How can I accomplish this? It appears that RSA encryption is required in this scenario.
SHA256 Signature
Hi, How can I create a SHA256 signature hash in D? Something similar to the PHP code below: ```php openssl_sign($body, $signature, $secret, OPENSSL_ALGO_SHA256); ``` I've tried the code below without success: ```d auto signature = body.representation.hmac!SHA256(secret.representation).toHexString!(LetterCase.lower).to!string; ```
Google Auth API
Hi, Has anyone here had experience implementing the Google Auth Library in DLang? Specifically, I am looking for guidance on handling OAuth 2.0 using JWT. Are there any current libraries available for this purpose?
Re: Convert String to Date and Add ±N Hours
On Saturday, 4 November 2023 at 19:19:43 UTC, Jonathan M Davis wrote: On Saturday, November 4, 2023 12:11:53 PM MDT Vahid via Digitalmars-d-learn wrote: [...] If you're using D's standard library, you would need to replace the space with a T so that the time format was ISO extended. Then you can use DateTime.fromISOEXtString() in std.datetim.date to get a DateTime. You can then add a duration to the DateTime to change its value - e.g. using hours(2) (or dur!"hours"(2) for the generic version). Then if you want a string again, toISOExtString will convert the DateTime to the ISO extended format, and if you want a space instead of a T, then just replace the T with a space in the string. E.G. [...] Thank you. It works very well.
Convert String to Date and Add ±N Hours
Hi, I have a date string with the format of "2023-11-04 23:10:20". I want to convert this string to Date object and also, add ±N hours to it. For example: `"2023-11-04 23:10:20" + "+2:00" = "2023-11-05 01:10:20"` `"2023-11-04 23:10:20" + "-2:30" = "2023-11-05 20:40:20"` How can I do this?
HTTP Post Body Parameters
Hi, I want to submit a request to server with "x-www-form-urlencoded" header. This is the simplified version of my code: auto http = HTTP("https://myurl.com/api;); http.addRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.addRequestHeader("Authorization", "SID:TOKEN"); auto params = "Param1=one=two"; http.setPostData(params, "application/x-www-form-urlencoded"); http.onReceive = (ubyte[] response) { return cast(string) response; }; http.perform(); This doesn't work as the server not receiving the parameters as post body. How can I send parameters as post body (or form data)? This is the RAW CURL version that I want to write using D: curl -X POST "https://myurl.com/api; \ --data-urlencode "Param1=one" \ --data-urlencode "Param2=two" \ -u SID:TOKEN