Answer the question
In order to leave comments, you need to log in
Can a person change the hash?
Hello!
The site has a chat, and so that users do not write on behalf of someone else (the username is set directly in the page code in the script), it was decided to create a hash with a unique user number, and when sending a message on the server, compare the sent hash with the hash of the received name.
But the following question arose: the
hash is created like this:
On the server, the check is as follows:md5($user['username']);
if(data.hash == md5(data.username)){
все ок
}else{
все не ок
}
Answer the question
In order to leave comments, you need to log in
First, MD5 has long been insecure. Secondly, do you have a server that does not check what came from the user?
can the user change his name through the codeIf there is such a possibility, then this is extremely bad.
it was decided to create a hash with a unique user numberThe hash must be unique for the duration of the user's session. So more salt needs to be added. If you want an extreme option, you take a hash from the user's uid, add a salt to it, and take the hash from all this again.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question