Answer the question
In order to leave comments, you need to log in
How to create a symmetric hash from two strings?
I'm not good at cryptography, so I'm asking for advice.
I have two strings
const str1 = "str1"
const str2 = "str2"
I need to get the same hash regardless of the order in which the strings are provided. Just a hash, not encrypting text with two keys
hash(str1, str2) === hash(str2, str1)
What algorithm in crypto would work for this?
Answer the question
In order to leave comments, you need to log in
Well, for example, take any hash function with a fixed result length (sha256) from both strings, and then parse character by character.
hash(str1, str2) = sha256(str1) ^ sha256(str2) = sha256(str2) ^ sha256(str1) = hash(str2, str1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question