null-routed / debank-hash-sign-v2

JS and Golang implementation of the core steps to generate a valid DeBank API frontend signature
6 stars 0 forks source link

Debank Hash Signature V2

Overview

This repository provides both JavaScript and Golang implementations of the signature mechanism used in DeBank's frontend API. DeBank uses this signature mechanism to secure the API calls done via their frontend. After a full reverse engineering of the DeBank frontend JavaScript code, I've reduced the signature process to its core components, eliminating unnecessary overhead.

How It Works

The core steps to generate the signature are:

  1. Initial String Creation: A string is generated by concatenating "debank-api" with a randomly generated nonce and the current UNIX timestamp. Each element is separated by a newline character.

  2. Request String Formation: A string representing the API request is created by concatenating the request method, the URL path, and URL parameters (previously alphabetically sorted). Each element is, again, separated by a newline character.

  3. SHA-256 Hashing: Both the initial and request strings are SHA-256 hashed and are then hex encoded.

  4. HMAC Authentication: The request string is authenticated using an HMAC process with SHA-256, utilizing the first string as the key.

Donations