Questions tagged [hmac]
In cryptography, HMAC (Hash-based Message Authentication Code) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret key.
1,406
questions
0
votes
0
answers
12
views
What are 'officially approved' implementations to anonymize LONG values (id in table) for GDRP requirements
I want to create an anonymized version of a table where one of the id fields (long) needs to be anonymized.
The table is queried by a huge number of different business stake holders so I would prefer ...
0
votes
0
answers
19
views
Empty buffer but toString has value
I'm trying to verify a slack request, so I have the following code
if (!timeStamp || !slackSignature) {
throw new Error('Missing Slack signature');
}
const time = Math.floor(new Date()....
0
votes
0
answers
33
views
Cannot Create a Valid Signature for Binance API using expo-crypto
Since node:crypto is not available in react native projects, I use expo-crypto package.
When I try to run the following code using node:crypto in a different project, it works perfectly fine:
const ...
0
votes
0
answers
38
views
Difference between these two HMAC excamples?
I have to calc HMAC signature to compare to the one from a message.
I come to two different results and do not understand the difference nor which one is correct.
I have even tested different online ...
-1
votes
1
answer
45
views
How can I SHA1-HMAC a string in Python
I've been trying to figure out how to use HMAC to hash a string in Python for a TOTP generator I've already made in PHP. In PHP, I use the command echo -n "0x00000000035362f9" | xxd -r -p | ...
0
votes
1
answer
42
views
How to convert HMAC Hash from python to node.js
I want to convert this snippet to Nodejs.
import urllib.request
import base64
import hmac
signature = hmac.new(SECRETKEY.encode("utf-8"), my_string.encode("utf-8"), digestmod=&...
0
votes
1
answer
33
views
Why the webhook signature sent by slack in the request header is not matching with the calculated webhook signature at our server?
The problem that we are facing is:
The webhook signature sent by slack in the request header is not matching with the calculated webhook signature at our server, but only for the first request that is ...
0
votes
0
answers
48
views
How to implement HMAC Authentication with .NET 5 Web API?
I have an ASP.NET Core 5 Web API in which JWT Bearer Authentication is applied (as shown below, and its working fine), for more security I want to add HMAC Authentication that should form as another ...
1
vote
0
answers
43
views
compute hmac from message bytes and key bytes in javascript
I'm trying to reproduce the following code in javascript
var hashInput = "a::string::to::hash";
var privateKey = "...
0
votes
0
answers
40
views
HMAC in Javascript does not match HMAC in Python because of quotes
I have a client in JavaScript that carries out hmac as follows:
generateHMAC: function (payload) {
return new Promise((resolve) => {
let hmacpsk = app.get('secret_key');
const hmac = crypto....
2
votes
1
answer
103
views
Trying to implement SimplePay (OTP) payment gateway in a NodeJS project, but I fail to get the same signature as in the tech documentation
I'm trying to implement SimplePay (OTP) payment gateway in a NodeJS project.
So far I'm only exploring and following the technical documentation, and try to put together the test start request as per ...
0
votes
0
answers
58
views
How to generate hmac in binary in Python and convert it into base64
I have the following code in bash and I want to convert it in Python.
#!/bin/bash
username="USERNAME"
apiKey='KEY'
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%...
1
vote
1
answer
167
views
What is createSecretKey for in nodejs crypto module?
Im trying to figure out why should I use createSecretKey in crypto module instead of string.
What difference between this:
const secret = crypto.createSecretKey('mysupersecret'); // Creates ...
0
votes
1
answer
77
views
Getting invalid signature for HMAC authentication of python pickle file
I am trying to use HMAC authentication for reading and write pickle files.
Sample Data :
import base64
import hashlib
import hmac
from datetime import datetime
import six
import pandas as pd
import ...
0
votes
0
answers
39
views
Sharing the secret key for HMAC based authentication for webhooks
I have just started implementing a webhook provider, where clients can register by providing their webhook address.
Most of the concepts are clear to me, and as I understood from various sources - we ...
0
votes
1
answer
182
views
"The specified key byte array is 192 bits which is not secure enough for any JWT HMAC-SHA algorithm... " error for mockmvc post request
I want to call write below code to write integration test for login in Kotlin:
@Test
fun userSignup() {
var result = this.mockMvc.perform(post("http://localhost/signup")
....
1
vote
1
answer
112
views
Securing Flutter mobile app register API endpoint from spam or bot attack
We have a live mobile application supporting registering with the user's mobile number.
We send OTP upon each register request and now we have hundreds of spam requests costing a lot of money due to ...
-1
votes
1
answer
133
views
How to verify password hash ( hash_hmac, sha512 ) in php?
I need to convert VerifyPasswordHash method in C# to php. I have salt and stored_hash in DB for this user.
stored_hash = ...
0
votes
0
answers
40
views
Youtube Pubsub Validate signature
I am creating an open Source Project which uses the youtube pubsub api to get notifications on video uploads. I want to verify that the request does come from youtube and not from a 3rd Party by ...
0
votes
1
answer
149
views
Derive An AWS Signing Key For Signature Version 4
I am attempting to generate a signing key for AWS according to AWS's documentation here for an iOS application. The documentation is pretty good however, it doesn't provide an example using Swift. ...
0
votes
0
answers
241
views
Magento 2 REST API OAuth HMAC-SHA256 signature generation
Magento ver 2.4.3
I am trying to call a Magento REST API using OAuth authentication. I can't seem to get the HMAC-SHA256 signature to generate correctly after I followed the official guidance at: ...
0
votes
0
answers
152
views
How to generate (and verify) a digital signature of a limited size in Python?
I'm building a trading application that send orders to the market and I would like to insert a unique signature in each order, so their authenticity can be verified later. When creating a new order, ...
2
votes
1
answer
45
views
analog in PHP [echo "symbol=LTC%2FBTC&side=BUY" | openssl dgst -sha256 -hmac "SECRETKEY" ]
I write code for send webhook in Currensy-Rest-api:
https://currency.com/ru/general-rest-api-information
for this i need to form signature HMAC sha256, in example of currensy i have
[echo "...
1
vote
2
answers
142
views
In Scala Play Framework, is there a simple way to verify signatures on form requests
I am trying to write a Scala Play Framework action that will verify a HmacSHA256 signature on an incoming POST request containing form-url-encoded data.
This does not seem straightforward in the Play ...
0
votes
0
answers
55
views
HmacSHA256 Signature Doesn't Match Expected Signature
I'm following this docs and I can't find a way of creating the right HmacSHA256 signature using Python. Based on the docs, the request signature should come from doing: HmacSHA256 (originString). ...
0
votes
0
answers
122
views
Is HMAC-SHA256 one way hashing or can I un hash the actual value
New to HMAC, trying to find out is HMAC is one way hashing or can I un hash the value back to it's original, bcz I see the key is using while calculating the hash.
1
vote
1
answer
372
views
ASP.NET Core 6 basic authentification problem with Postman post method
I have this return error in Postman when calling post method but project works for get method. Project is a simple Web API with custom basic auth with X-UserID and Request body check with hmac hash:
{...
0
votes
0
answers
171
views
Accessing API with HMAC hashkey from secret key in Python
I am currently attempting to utilise the full-access coin spot API (https://www.coinspot.com.au/v2/api). I have my API key and secret. The API requires post data to be signed with the secret key using ...
0
votes
1
answer
22
views
Transcription of hash_hmac and hex2bin PHP functions to NodeJS
I have a PHP script which use HMAC and a key to generate a hash. It works well:
$payload = '1605697463367HELLO';
$key = '...
0
votes
0
answers
44
views
Signature validation always returns False
I am trying to validate the post request coming from Typeform. Their docs on how to do it are here, BUT it does not work. So I have implemented the following :
def verifySignature(request):
...
0
votes
1
answer
621
views
openssl library: aes-256-cbc vs aes-256-cbc-hmac-sha256
The openssl_get_cipher_methods() function returns, within the list of available algorithms, both aes-256-cbc and aes-256-cbc-hmac-sha256 so I was trying to understand how to use them with the ...
0
votes
0
answers
93
views
Powershell HMAC (SHA256) - Error & Authorisation
Recently inherited a bit of a nightmare. Trying to get my head around saving an API to a text file for processing etc. I've landed on Powershell (open to other/better ideas) but I'm having trouble ...
0
votes
1
answer
166
views
how do i generate a signature from given input and a secret key?
I'm trying to use AWS api to get keys from Secrets Manager using an internal linux server (using cURL). now i constructed a postman payload that works, but i noticed that the signature digest is ...
1
vote
1
answer
1k
views
Send an encrypted request to APi in Dart
I am trying to send an encrypted request to a specific API in dart, but without success - I don't have any experience with the Dart language.
This are the requirements:
The JSON to be sent is ...
-1
votes
1
answer
33
views
How do you convert "final String webhookSignature = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, webhookSecret).hmacHex(webhookBody);" from java to python [closed]
I'm just not experienced enough in java to figure this out, but if anyone knows the equivalent of this code in python, that would be greatly appreciated:
final String webhookSignature = new HmacUtils(...
0
votes
1
answer
102
views
What to put in query string in post request? -NiceHash API
I am working on a python program that turns on/off my mining rig with Nicehash API. I did everything that I need to but I am stuck with what to put in query string.
In header of post request must be X-...
0
votes
0
answers
575
views
Java equivalent of CryptoJS.enc.Base64 for encryption
've been trying to port some NodeJS code to Java in order to make HMAC signed requests to an API. I've been able to simplify the code to a point were encoding is clearly affecting the output.
Here's ...
1
vote
1
answer
139
views
Implement HMAC in Azure Function HTTP Trigger
I was asked to implement HMAC in Azure Function that receives web-hooks requests but I don't find documentations that give me an idea of how to do that. Any suggestion would be great help.
1
vote
1
answer
157
views
HMAC Validation in SpringBoot failing due to rearrangement of JSON
I am trying to have HMAC in springBoot for REST API.
The request I send from Postman is
{
"name":"xyz",
"description":"hello world",
"phone&...
0
votes
1
answer
54
views
Replicating HMAC from C# to Python
I'm working with an API provided by a client, who provided sample code on authorizing via C#, but my company works in Python. They authorize via HMAC, and following their sample code (on .net fiddle), ...
2
votes
0
answers
39
views
Does ctx need to be freed and re-newed for multi-HMACs
Using the EVP_MAC functions, if I am performing multiple MACs do I need to free and new the ctx for each MAC or is the init function sufficient.
Can I
EVP_MAC_CTX_new,
multipe EVP_MAC_init, ...
0
votes
0
answers
101
views
HMAC API authentication not working (Python3.10)
I'm trying to requests in Python to talk to a REST API which requires a HMAC authorization header.
Specifically, I want to implement a simple working example using the (publicly readable) SMS Global ...
0
votes
1
answer
195
views
PHP implementation of PBKDF2WithHmacSHA256 from Java
I have the following Java implementation of the hashing algorithm:
public String encrypt(@NotNull String value) {
String ret = null;
var iv = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
3
votes
1
answer
2k
views
How do I validate the Hmac using NodeJS?
I can successfully create an Hmac via NodeJS using the following code:
(slightly altered example from : https://nodejs.org/api/crypto.html#cryptocreatehmacalgorithm-key-options)
Crypto.createHmac('...
0
votes
1
answer
147
views
different utf8 encoding outputs between Python and Haskell
I'm trying to encode a has which is computed by hmac sha256 in Haskell and sometimes my function has different output when compared to it's Python counterpart.
This is the python funciton:
import ...
0
votes
0
answers
192
views
Dlocal Payment HMAC-SHA256
I am integrating a payment gateway to my website and to send the payment signature I need to create a HMAC-SHA256 hash and include it in the header.
The documentation only gives me examples in PHP, ...
3
votes
1
answer
96
views
Adapting An Encryption Algorithm Written in Javascript to Java
To summarize my problem, I want to adapt an encryption algorithm written in Javascript to the Java side. The content produced here is used in the header of the service I am calling. But even though I ...
0
votes
0
answers
37
views
how to secure hmac key in haproxy configuration file
i want to use hmac to secure request in haproxy configuration like this:
http-request set-header Signature %[var(src),hmac(sha256, xxx),hex,lower]
however, everyone who can read haproxy configuration ...
1
vote
1
answer
938
views
OPENSSL_API_COMPAT expresses an impossible API compatibility level c++
#error: "OPENSSL_API_COMPAT expresses an impossible API compatibility level" why when I import these 2 lines of code it gives me the error above?
#define OPENSSL_API_COMPAT 0x10101000L
#...
0
votes
0
answers
743
views
C# Checking HMAC SHA256 from API
I'm trying to validate a hmac sha256 key that an API sends to me in a header. I don't fully understand how to validate this, can anoyone point me in the right direction?
From the API reference:
Every ...