# DeviceConnect: Salt Generation
Salt is generated at the client side for Authentication
# Calculate salt
Salt is calculated as follows:
- A = Create MD5 hash of
CUSTOMER_ID
- B = Concatenate string of A and
SERVER_HASH
shared by FinBox. - C = Create an SHA-256 hash of B
- Salt = base64 encoded version of C
Sample code for salt generation in different languages:
- Python
- Go
- Java
- C#
- PHP
- Ruby
- JavaScript
import hashlib, base64
def create_salt(customer_id, server_hash):
"""
Takes customer_id (unique identifier of customer)
and server_hash (shared by FinBox) as input
and returns salt in response
"""
customer_hash = hashlib.md5(customer_id.encode('utf-8')).hexdigest().upper()
intermediate_hash = customer_hash + server_hash
salt_encoded = hashlib.sha256(intermediate_hash.encode('utf-8')).digest()
salt = base64.b64encode(salt_encoded).decode()
return salt
# Debug Salt Generation
You can cross check each individual step of your salt generation logic by using the following parameters
customer_id = 82169C6312B50CA8233482169F9F288F812B5C02114A6A74E9A62
server_hash = 5f8cd80c69a34b9785dc66298eabe95b
Step A Result - Hexdigest of MD5Hash
7B85689C14D32209779241F14A09C29B
Step B Result - Intermediate Hash
7B85689C14D32209779241F14A09C29B5f8cd80c69a34b9785dc66298eabe95b
Step C Result - Hexdigest Version
2a2e163b66dbcd838bd6d122e17038e90f2ba5c0b6ca295364c84e19746ca8e4
Note: The result for Step C shared above is generated by doing a hexdigest rather than a digest. It is shared for comparison purposes only. In the actual code you must use digest rather than haxdigest for Step 3.
Final Result - Salt
Ki4WO2bbzYOL1tEi4XA46Q8rpcC2yilTZMhOGXRsqOQ=
← Insights API FAQ →