In this system, during registration, the server stores the username, the number of authentications (n), and the password. n indicates the number of times the user can log in. The client processes the password n times using the SHA-1 hashing algorithm and sends the final hash value to the server for storage in the database.
During the authentication phase, the client first sends the username, and the server returns the value of n to the client. The client then hashes the password n-1 times and sends the hashed value to the server. The server hashes this value once more and compares it with the hash stored in the database. If these two values match, the authentication is successful, and the server decreases the value of n to n-1, replacing it with the user-sent hash of n-1. This process continues until n reaches 1, at which point the user must re-register. This method helps maintain the security of passwords and manage the number of authentication attempts. This approach is based on Lamport's one-time password system.