Imports System.Security.Cryptography Imports System.Text Module Module1 Sub Main() Dim secret_key = "a7d0cb1da1ddbc86c96ee5fedd341b7d8ebfbb2f5c83cfe0909f4e57f05dd403" Dim plain_text = String.Join(vbCrLf, New String() {"POST", "https://sellerapi.kaufland.com/v2/units/", "", "1411055926"}) Dim lcSignature = getShopSignature(secret_key, plain_text) Console.WriteLine(lcSignature) Console.ReadLine() 'result must be "da0b65f51c0716c1d3fa658b7eaf710583630a762a98c9af8e9b392bd9df2e2a" End Sub Private Function getShopSignature(tcKey As String, tcMessage As String) As String Dim lcKeyBytes As Byte() = Encoding.Default.GetBytes(tcKey) Dim lcMessageBytes As Byte() = Encoding.Default.GetBytes(tcMessage) Using loHmacSha256 As New HMACSHA256(lcKeyBytes) Dim lcHashMessage As Byte() = loHmacSha256.ComputeHash(lcMessageBytes) Dim lcHexString As String = byteArrayToString(lcHashMessage) Return lcHexString End Using End Function Public Function byteArrayToString(ByVal ba As Byte()) As String Dim hex As StringBuilder = New StringBuilder(ba.Length * 2) For Each b In ba hex.AppendFormat("{0:x2}", b) Next Return hex.ToString() End Function End Module
import hmac import hashlib import time def sign_request(method, uri, body, timestamp, secret_key): digest_maker = hmac.new(secret_key.encode(), None, hashlib.sha256) digest_maker.update(plain_text.encode()) test = digest_maker.digest() return digest_maker.hexdigest() method = "POST" uri = "https://sellerapi.kaufland.com/v2/units/" body = "" timestamp = 1411055926 # time.time() secret_key = "a7d0cb1da1ddbc86c96ee5fedd341b7d8ebfbb2f5c83cfe0909f4e57f05dd403" print(sign_request(method, uri, body, timestamp, secret_key)) # da0b65f51c0716c1d3fa658b7eaf710583630a762a98c9af8e9b392bd9df2e2a
String.Join(vbCrLf, New String()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)