Salami abi... @gwumex 2 years ago great tutorial
Create user authentication in blockchain using solidity and remix ide
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.8;
contract AuthSystem{
struct Users{
string username;
uint256 password;
}
Users[] public AllUsers;
function CreateAccount(string memory _username, uint256 _password) public{
AllUsers.push(Users(_username, _password));
}
function Login(string memory _username, uint256 _password) public view returns(string memory){
for (uint256 i = 0; i < AllUsers.length; i++){
if(keccak256(abi.encodePacked(AllUsers[i].username)) == keccak256(abi.encodePacked(_username))){
if(AllUsers[i].password == _password){
return 'Logged in';
}else{
return 'User found but Incorrect Password';
}
}
}
return 'User Not Found';
}
}
I take lessons on various blockchain courses reach out to me @ nablintech@gmail.com