Skip to content

May I ask if this plugin supports HMAC_SHA256 calculation by inputting hex key as well as string data, the plugin will convert the input hex key to binary and string data for calculation, and the blueprint outputs the hex calculation result. #1

@592827369

Description

@592827369

Hello, I ran into a problem during the use of the plugin, I used HMAC_SHA256 to calculate, String=cvm,Key=f1cb4d518a0eda9d5cbbfdb7850983f1e603eeae484edea76e4dd8d8deb5556e, and according to the Cloud Service Provider API's The documentation calculates that the result should be: f1cb4d518a0eda9d5cbbfdb7850983f1e603eeae484edea76e4dd8d8deb5556e, but I use the plugin to calculate the result as: 001750140C680A8CF4F08F7897EC77B4F70C5D779CDFC754FE7C64A7DF7F1097, after I tried to use other plug-ins, found that it is the same result, because I do not know how to use C + + +, I asked chatgpt after it gave me a piece of python code to calculate the result with the api I asked chatgpt and it gave me a python code to calculate the result with the api example. I look at the comments and found that it is the key into binary after the calculation, after the blueprint output hexadecimal results, I would like to ask whether the current plug-ins do not support this approach? If it does not support the subsequent time to consider adding, this problem has trapped me for a very long time, other plug-ins are also such a situation. chatgpt and the sample calculation results consistent with the code is as follows:

import hashlib
import hmac
import binascii

def hmac_sha256(key, message):: return hmac.new(key, message).
return hmac.new(key, message.encode('utf-8'), hashlib.sha256).digest()

Input parameters

secret_signing_hex = “f1cb4d518a0eda9d5cbbfdb7850983f1e603eeae484edea76e4dd8d8deb5556e”
string_to_sign = (
“cvm”
)

Convert hexadecimal key to binary

secret_signing = binascii.unhexlify(secret_signing_hex)

Calculate the signature

signature = hmac_sha256(secret_signing, string_to_sign)
signature_hex = binascii.hexlify(signature).decode('utf-8')

print(“Signature:”, signature_hex)

Translated with DeepL.com (free version)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions