public static void HandleAccountCreate(Session session, params string[] parameters) { uint accountId = DatabaseManager.Authentication.GetMaxId() + 1; string account = parameters[0].ToLower(); string salt = SHA2.Hash(SHA2Type.SHA256, Path.GetRandomFileName()); string password = SHA2.Hash(SHA2Type.SHA256, parameters[1]); AccessLevel accessLevel = AccessLevel.Player; if (parameters.Length > 2) { if (Enum.TryParse(parameters[2], true, out accessLevel)) { if (!Enum.IsDefined(typeof(AccessLevel), accessLevel)) { accessLevel = AccessLevel.Player; } } } string articleAorAN = "a"; if (accessLevel == AccessLevel.Advocate || accessLevel == AccessLevel.Admin || accessLevel == AccessLevel.Envoy) { articleAorAN = "an"; } Account acc = new Account(accountId, account, accessLevel, salt, password); DatabaseManager.Authentication.CreateAccount(acc); Console.WriteLine("Account successfully created for " + account + " with access rights as " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + "."); }
public Account(uint accountId, string name, string salt, string password) { AccountId = accountId; Name = name; Salt = salt; Password = password; Digest = SHA2.Hash(SHA2Type.SHA256, password + salt); }
public static void HandleAccountCreate(Session session, params string[] parameters) { uint accountId = DatabaseManager.Authentication.GetMaxId() + 1; string account = parameters[0].ToLower(); string salt = SHA2.Hash(SHA2Type.SHA256, Path.GetRandomFileName()); string password = SHA2.Hash(SHA2Type.SHA256, parameters[1]); Account acc = new Account(accountId, account, salt, password); DatabaseManager.Authentication.CreateAccount(acc); }
public static void HandleAccountCreate(Session session, params string[] parameters) { var result = DatabaseManager.Authentication.SelectPreparedStatement(AuthenticationPreparedStatement.AccountMaxIndex); Debug.Assert(result != null); uint accountId = result.Read <uint>(0, "MAX(`id`)") + 1; string salt = SHA2.Hash(SHA2Type.SHA256, Path.GetRandomFileName()); string password = SHA2.Hash(SHA2Type.SHA256, parameters[1]); string digest = SHA2.Hash(SHA2Type.SHA256, password + salt); DatabaseManager.Authentication.ExecutePreparedStatement(AuthenticationPreparedStatement.AccountInsert, accountId, parameters[0], digest, salt); }
private void button1_Click(object sender, EventArgs e) { var password = SHA2.Hash(textBox2.Text); if (_client.Login(textBox1.Text, password)) { var formMain = new MyCloudStoreClientForm(textBox1.Text); formMain.Show(); this.Hide(); } else { MessageBox.Show("Wrong username or password!!! Try again!!!", "Wrong credentials", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void AccountSelectCallback(MySqlResult result, Session session) { var connectResponse = new ServerPacket(0x0B, PacketHeaderFlags.ConnectRequest); connectResponse.Payload.Write(0u); connectResponse.Payload.Write(0u); connectResponse.Payload.Write(13626398284849559039ul); // some sort of check value? connectResponse.Payload.Write((ushort)0); connectResponse.Payload.Write((ushort)0); connectResponse.Payload.Write(ISAAC.ServerSeed); connectResponse.Payload.Write(ISAAC.ClientSeed); connectResponse.Payload.Write(0u); NetworkManager.SendPacket(ConnectionType.Login, connectResponse, session); if (result.Count == 0) { session.SendCharacterError(CharacterError.AccountDoesntExist); return; } uint accountId = result.Read <uint>(0, "id"); string account = result.Read <string>(0, "account"); if (WorldManager.Find(account) != null) { session.SendCharacterError(CharacterError.AccountInUse); return; } string digest = SHA2.Hash(SHA2Type.SHA256, result.Read <string>(0, "password") + result.Read <string>(0, "salt")); /*if (glsTicket != digest) * { * }*/ /*if (WorldManager.ServerIsFull()) * { * session.SendCharacterError(CharacterError.LogonServerFull); * return; * }*/ // TODO: check for account bans session.SetAccount(accountId, account); }
private void btnOK_Click(object sender, EventArgs e) { _redisClient.Hashes[txtUsername.Text]["password"] = SHA2.Hash(txtPassword.Text); DialogResult = DialogResult.OK; this.Close(); }
private string GetHash(byte[] file) { return(SHA2.Hash(file)); }