private static byte[] ArgonHash(string password, byte[] saltBytes) { var hashBytes = PasswordHash.ArgonHashBinary( Encoding.UTF8.GetBytes(password), saltBytes, PasswordHash.StrengthArgon.Sensitive, 512); return(hashBytes); }
public void ArgonHashBinary128Test() { const string PASSWORD = "******"; const string SALT = "qa~t](84z<1t<1oz"; const long OUTPUT_LENGTH = 128; var hash1 = PasswordHash.ArgonHashBinary(PASSWORD, SALT, PasswordHash.StrengthArgon.Interactive, OUTPUT_LENGTH); var hash2 = PasswordHash.ArgonHashBinary(PASSWORD, SALT, PasswordHash.StrengthArgon.Interactive, OUTPUT_LENGTH); Assert.AreEqual(OUTPUT_LENGTH, hash1.Length); Assert.AreEqual(OUTPUT_LENGTH, hash2.Length); Assert.AreEqual(hash1, hash2); }
public static byte[] ArgonHashBinary(SecureString password, SecureString salt) { Guard.Argument(password, nameof(password)).NotNull(); Guard.Argument(salt, nameof(salt)).NotNull(); byte[] hash; using (var insecurePassword = password.Insecure()) using (var insecureSalt = salt.Insecure()) { hash = PasswordHash.ArgonHashBinary(insecurePassword.Value.FromHex(), insecureSalt.Value.FromHex(), PasswordHash.StrengthArgon.Moderate, 32); } return(hash); }
public void ArgonHashBinary16ByteTest() { const string PASSWORD = "******"; const string SALT = "44071f6d181561670bda728d43fb79b4"; const long OUTPUT_LENGTH = 16; var hash1 = PasswordHash.ArgonHashBinary(Utilities.HexToBinary(PASSWORD), Utilities.HexToBinary(SALT), PasswordHash.StrengthArgon.Interactive, OUTPUT_LENGTH); var hash2 = PasswordHash.ArgonHashBinary(Utilities.HexToBinary(PASSWORD), Utilities.HexToBinary(SALT), PasswordHash.StrengthArgon.Interactive, OUTPUT_LENGTH); Assert.AreEqual(OUTPUT_LENGTH, hash1.Length); Assert.AreEqual(OUTPUT_LENGTH, hash2.Length); Assert.AreEqual(hash1, hash2); }
public static (byte[] encryptionKey, byte[] macKey) DeriveKeys(byte[] passwordBytes, byte[] salt, int iterations, int memorySize) { var argon2id = PasswordHash.ArgonAlgorithm.Argon_2ID13; MemoryEncryption.DecryptByteArray(ref passwordBytes); // Derive a 96 byte key byte[] derivedKey = PasswordHash.ArgonHashBinary(passwordBytes, salt, iterations, memorySize, Constants.Argon2KeySize, argon2id); // 256-bit encryption key byte[] encryptionKey = new byte[Constants.EncryptionKeySize]; Array.Copy(derivedKey, encryptionKey, encryptionKey.Length); // 512-bit MAC key byte[] macKey = new byte[Constants.MACKeySize]; Array.Copy(derivedKey, encryptionKey.Length, macKey, 0, macKey.Length); Utilities.ZeroArray(derivedKey); MemoryEncryption.EncryptByteArray(ref passwordBytes); MemoryEncryption.EncryptByteArray(ref encryptionKey); MemoryEncryption.EncryptByteArray(ref macKey); return(encryptionKey, macKey); }
public void OnGet() { String PrivateKeyString = HttpContext.Session.GetString("PrivateKeyString"); String PublicKeyString = ""; String ID = HttpContext.Session.GetString("Chat_ID"); String Exception = ""; Boolean CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); MySqlCommand MySQLQuery = new MySqlCommand(); MySqlDataReader RecordReader; List <BigInteger> MessageIntList = new List <BigInteger> { }; List <BigInteger> SaltIntList = new List <BigInteger> { }; List <BigInteger> NonceIntList = new List <BigInteger> { }; Byte[] CurrentMessageByte = new Byte[] { }; Byte[] CurrentSaltByte = new Byte[] { }; Byte[] CurrentNonceByte = new Byte[] { }; Byte[] PrivateKeyByte = new Byte[] { }; Byte[] PublicKeyByte = new Byte[] { }; Byte[] SharedSecretByte = new Byte[] { }; Byte[] DerivedKeyByte = new Byte[] { }; Byte[] DecryptedMessageByte = new Byte[] { }; BigInteger PrivateKey = 0; BigInteger PublicKey = 0; BigInteger DerivedKeyInt = 0; int Loop = 0; int Checker = 0; long OUTPUT_LENGTH = 32; Current_User = HttpContext.Session.GetString("User_Name"); if (PrivateKeyString != null && ID != null && Current_User != null) { MySQLQuery.CommandText = "SELECT COUNT(*) FROM `DF_Public_Key` WHERE `Requestor_1`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); Checker = int.Parse(MySQLQuery.ExecuteScalar().ToString()); if (Checker == 1) { MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Requestor_2_PK`,`Requestor_2` FROM `DF_Public_Key` WHERE `Requestor_1`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); RecordReader = MySQLQuery.ExecuteReader(); while (RecordReader.Read()) { PublicKeyString = RecordReader.GetValue(0).ToString(); Other_User = RecordReader.GetValue(1).ToString(); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); } else { MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Requestor_1_PK`,`Requestor_1` FROM `DF_Public_Key` WHERE `Requestor_2`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); RecordReader = MySQLQuery.ExecuteReader(); while (RecordReader.Read()) { PublicKeyString = RecordReader.GetValue(0).ToString(); Other_User = RecordReader.GetValue(1).ToString(); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); } CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); PublicKey = BigInteger.Parse(PublicKeyString); PublicKeyByte = PublicKey.ToByteArray(); PrivateKey = BigInteger.Parse(PrivateKeyString); PrivateKeyByte = PrivateKey.ToByteArray(); SharedSecretByte = ScalarMult.Mult(PrivateKeyByte, PublicKeyByte); MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT COUNT(*) FROM `Chat_Message` WHERE `FK_ID`=@FK_ID"; MySQLQuery.Parameters.Add("@FK_ID", MySqlDbType.Text).Value = ID; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); Current_Count = int.Parse(MySQLQuery.ExecuteScalar().ToString()); MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "UPDATE `Chat_Message` SET `Receiver_Status`=@Receiver_Status WHERE `FK_ID`=@FK_ID AND `Receiver_Status`!=@Receiver_Status AND `Sender_Name`!=@Current_User"; MySQLQuery.Parameters.Add("@FK_ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Receiver_Status", MySqlDbType.Text).Value = "Received"; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); MySQLQuery.ExecuteNonQuery(); MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Salt`,`Nonce`,`Message`,`Sender_Name`,`Receiver_Status` FROM `Chat_Message` WHERE `FK_ID`=@FK_ID"; MySQLQuery.Parameters.Add("@FK_ID", MySqlDbType.Text).Value = ID; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); RecordReader = MySQLQuery.ExecuteReader(); while (RecordReader.Read()) { SaltIntList.Add(BigInteger.Parse(RecordReader.GetValue(0).ToString())); NonceIntList.Add(BigInteger.Parse(RecordReader.GetValue(1).ToString())); MessageIntList.Add(BigInteger.Parse(RecordReader.GetValue(2).ToString())); Sender_NameList.Add(RecordReader.GetValue(3).ToString()); Receiver_StatusList.Add(RecordReader.GetValue(4).ToString()); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); Loop = 0; while (Loop < SaltIntList.Count) { CurrentSaltByte = SaltIntList[Loop].ToByteArray(); CurrentNonceByte = NonceIntList[Loop].ToByteArray(); CurrentMessageByte = MessageIntList[Loop].ToByteArray(); if (Loop == 0) { DerivedKeyByte = PasswordHash.ArgonHashBinary(SharedSecretByte, CurrentSaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); } else { DerivedKeyByte = PasswordHash.ArgonHashBinary(DerivedKeyByte, CurrentSaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); } DecryptedMessageByte = SecretBox.Open(CurrentMessageByte, CurrentNonceByte, DerivedKeyByte); Message_List.Add(Encoding.UTF8.GetString(DecryptedMessageByte)); Loop += 1; } HttpContext.Session.SetString("CurrentCount", Current_Count.ToString()); if (aTimer == null) { SetRefreshTimer(); } } }
public void HashArgonLongTest() { try { //Could cause OutOfMemoryException //Some of the values are from: https://github.com/jedisct1/libsodium/blob/master/test/default/pwhash_scrypt.c var testObjects = new List <HashTestObject> { new HashTestObject { Password = "******", Salt = "5541fbc995d5c197ba290346d2c559de", OpsLimit = 5, MemLimit = 7256678, OutputLength = 155 }, new HashTestObject { Password = "******", Salt = "f1192dd5dc2368b9cd421338b2243345", OpsLimit = 4, MemLimit = 7849083, OutputLength = 250 }, new HashTestObject { Password = "******", Salt = "3b840e20e9555e9fb031c4ba1f1747ce", OpsLimit = 3, MemLimit = 7994791, OutputLength = 249 }, new HashTestObject { Password = "******", Salt = "eb2a3056a09ad2d7d7f975bcd707598f", OpsLimit = 4, MemLimit = 1397645, OutputLength = 152 }, new HashTestObject { Password = "******", Salt = "39d82eef32010b8b79cc5ba88ed539fb", OpsLimit = 3, MemLimit = 1432947, OutputLength = 82 }, new HashTestObject { Password = "******", Salt = "039c056d933b475032777edbaffac50f", OpsLimit = 3, MemLimit = 4886999, OutputLength = 156 }, new HashTestObject { Password = "******", Salt = "3d968b2752b8838431165059319f3ff8", OpsLimit = 3, MemLimit = 1784128, OutputLength = 220 } }; foreach (var testObject in testObjects) { Assert.AreEqual(testObject.OutputLength, PasswordHash.ArgonHashBinary(Utilities.HexToBinary(testObject.Password), Utilities.HexToBinary(testObject.Salt), testObject.OpsLimit, testObject.MemLimit, testObject.OutputLength) .Length); Assert.AreEqual(testObject.OutputLength, PasswordHash.ArgonHashBinary(Utilities.HexToBinary(testObject.Password), Utilities.HexToBinary(testObject.Salt), testObject.OpsLimit, testObject.MemLimit, testObject.OutputLength, PasswordHash.ArgonAlgorithm.Argon_2ID13).Length); } } catch (OutOfMemoryException e) { Assert.Inconclusive(e.ToString()); } }
public static byte[] KeyHash(byte[] passPhraseBytes, byte[] saltBytes) { byte[] keyHash = PasswordHash.ArgonHashBinary(passPhraseBytes, saltBytes, 2, 67108864, 32); return(keyHash); }
public static byte[] DeriveKey(byte[] passwordBytes, byte[] salt) { return(PasswordHash.ArgonHashBinary(passwordBytes, salt, Constants.Iterations, Constants.MemorySize, Constants.EncryptionKeyLength, PasswordHash.ArgonAlgorithm.Argon_2ID13)); }
public static KeyPair ImportFromKeystore(Wallet wallet, string input, int len, JsonSerializerSettings jsonSettings) { Contract.Assert(!string.IsNullOrWhiteSpace(wallet.PasswordHash)); var passwordHashBytes = Encoding.UTF8.GetBytes(wallet.PasswordHash); var kstore = JsonConvert.DeserializeObject <Keystore>(input, jsonSettings); if (kstore.Version != KeystoreVersion) { throw new NotSupportedException("Unsupported version"); } string kdfTypeString = kstore.Crypto.Kdf; if (!Enum.TryParse(kdfTypeString, true, out KdfType kdfType)) { throw new NotSupportedException("Unsupported kdf"); } byte[] derivedKey; switch (kdfType) { case KdfType.Scrypt: { derivedKey = PasswordHash.ScryptHashBinary( passwordHashBytes, kstore.Crypto.KdfParameters.Salt.FromHex(), PasswordHash.Strength.Sensitive, kstore.Crypto.KdfParameters.DerivedKeyLength); break; } case KdfType.Argon: { derivedKey = PasswordHash.ArgonHashBinary( passwordHashBytes, kstore.Crypto.KdfParameters.Salt.FromHex(), PasswordHash.StrengthArgon.Sensitive, kstore.Crypto.KdfParameters.DerivedKeyLength); break; } default: throw new NotSupportedException("Unsupported kdf"); } string ciphertext = kstore.Crypto.CipherText; string mac = kstore.Crypto.Mac; string iv = kstore.Crypto.CipherParameters.Iv; byte[] nonce = derivedKey.Take(len).ToArray(); byte[] seed = SecretBox.OpenDetached(ciphertext, mac.FromHex(), nonce, iv.FromHex()); var imported = new KeyPair( wallet.KeyPairs.Count + 1, kstore.Address.FromHex(), seed); wallet.KeyPairs.Add(imported); return(imported); }
public static string ExportToKeystore(KdfType kdfType, Wallet wallet, byte[] address, JsonSerializerSettings jsonSettings) { Contract.Assert(!string.IsNullOrWhiteSpace(wallet.PasswordHash)); var passwordHashBytes = Encoding.UTF8.GetBytes(wallet.PasswordHash); var salt = CryptoUtil.RandomBytes(32); var kdfparams = new { dklen = 32, salt = salt.ToHex() }; byte[] derivedKey; switch (kdfType) { case KdfType.Scrypt: { derivedKey = PasswordHash.ScryptHashBinary(passwordHashBytes, salt, PasswordHash.Strength.Sensitive, kdfparams.dklen); break; } case KdfType.Argon: { derivedKey = PasswordHash.ArgonHashBinary(passwordHashBytes, salt, PasswordHash.StrengthArgon.Sensitive, kdfparams.dklen); break; } default: throw new NotSupportedException("Unsupported kdf"); } var iv = CryptoUtil.RandomBytes(32); var pKey = wallet.GetPrivateKeyByAddress(address); var nonce = derivedKey.Take(24).ToArray(); var box = SecretBox.CreateDetached(pKey, nonce, iv); var keystore = new Keystore { Version = KeystoreVersion, Id = wallet.Id, Address = address.ToHex(), Crypto = new KeystoreCrypto { CipherText = box.CipherText.ToHex(), CipherParameters = new KeystoreCryptoParameters { Iv = iv.ToHex() }, Cipher = "crypto_secretbox_detached", Kdf = kdfType.ToString().ToLowerInvariant(), KdfParameters = new KeystoreKdfParameters { Salt = kdfparams.salt, DerivedKeyLength = kdfparams.dklen, }, Mac = box.Mac.ToHex() } }; return(JsonConvert.SerializeObject(keystore, Formatting.None, jsonSettings)); }
public byte[] Derive(byte[] bytes, int outputLen) { return(PasswordHash.ArgonHashBinary(bytes, Salt, OpsLimit, MemLimit, outputLen, PasswordHash.ArgonAlgorithm.Argon_2ID13)); }
public void OnPost() { String PrivateKeyString = HttpContext.Session.GetString("PrivateKeyString"); String ID = HttpContext.Session.GetString("Chat_ID"); String Current_User = HttpContext.Session.GetString("User_Name"); String Chat_Message = Request.Form["Chat_Message"]; String Exception = ""; Boolean CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); MySqlCommand MySQLQuery = new MySqlCommand(); MySqlDataReader PublicKeyStringReader; MySqlDataReader RecordReader; String PublicKeyString = ""; BigInteger PrivateKey = 0; BigInteger Nonce = 0; BigInteger PublicKey = 0; BigInteger MessageInt = 0; BigInteger SaltInt = 0; Byte[] NonceByte = new Byte[] { }; Byte[] PrivateKeyByte = new Byte[] { }; Byte[] PublicKeyByte = new Byte[] { }; Byte[] SharedSecretByte = new Byte[] { }; Byte[] MessageByte = new Byte[] { }; Byte[] SaltByte = new Byte[] { }; Byte[] NewKeyByte = new Byte[] { }; int Checker = 0; int Count = 1; long OUTPUT_LENGTH = 32; if (Chat_Message != null) { MySQLQuery.CommandText = "SELECT COUNT(*) FROM `DF_Public_Key` WHERE `Requestor_1`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); Checker = int.Parse(MySQLQuery.ExecuteScalar().ToString()); if (Checker == 1) { MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Requestor_2_PK` FROM `DF_Public_Key` WHERE `Requestor_1`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); PublicKeyStringReader = MySQLQuery.ExecuteReader(); while (PublicKeyStringReader.Read()) { PublicKeyString = PublicKeyStringReader.GetValue(0).ToString(); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); } else { MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Requestor_1_PK` FROM `DF_Public_Key` WHERE `Requestor_2`=@Current_User AND `ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); PublicKeyStringReader = MySQLQuery.ExecuteReader(); while (PublicKeyStringReader.Read()) { PublicKeyString = PublicKeyStringReader.GetValue(0).ToString(); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); } CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); PublicKey = BigInteger.Parse(PublicKeyString); PublicKeyByte = PublicKey.ToByteArray(); PrivateKey = BigInteger.Parse(PrivateKeyString); PrivateKeyByte = PrivateKey.ToByteArray(); SharedSecretByte = ScalarMult.Mult(PrivateKeyByte, PublicKeyByte); MySQLQuery = new MySqlCommand(); Checker = 0; MySQLQuery.CommandText = "SELECT COUNT(*) FROM `Chat_Message` WHERE `FK_ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); Checker = int.Parse(MySQLQuery.ExecuteScalar().ToString()); if (Checker != 0) { MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "SELECT `Salt` FROM `Chat_Message` WHERE `FK_ID`=@ID"; MySQLQuery.Parameters.Add("@ID", MySqlDbType.Text).Value = ID; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); RecordReader = MySQLQuery.ExecuteReader(); while (RecordReader.Read()) { SaltInt = BigInteger.Parse(RecordReader.GetValue(0).ToString()); SaltByte = SaltInt.ToByteArray(); if (Count == 1) { NewKeyByte = PasswordHash.ArgonHashBinary(SharedSecretByte, SaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); } else { NewKeyByte = PasswordHash.ArgonHashBinary(NewKeyByte, SaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); } Count += 1; } } if (NewKeyByte.Length == 0) { SaltByte = PasswordHash.ArgonGenerateSalt(); NewKeyByte = PasswordHash.ArgonHashBinary(SharedSecretByte, SaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); SaltInt = new BigInteger(SaltByte); NonceByte = SecretBox.GenerateNonce(); MessageByte = SecretBox.Create(Encoding.UTF8.GetBytes(Chat_Message), NonceByte, NewKeyByte); MessageInt = new BigInteger(MessageByte); Nonce = new BigInteger(NonceByte); } else { SaltByte = PasswordHash.ArgonGenerateSalt(); NewKeyByte = PasswordHash.ArgonHashBinary(NewKeyByte, SaltByte, PasswordHash.StrengthArgon.Medium, OUTPUT_LENGTH, PasswordHash.ArgonAlgorithm.Argon_2ID13); SaltInt = new BigInteger(SaltByte); NonceByte = SecretBox.GenerateNonce(); MessageByte = SecretBox.Create(Encoding.UTF8.GetBytes(Chat_Message), NonceByte, NewKeyByte); MessageInt = new BigInteger(MessageByte); Nonce = new BigInteger(NonceByte); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); MySQLQuery = new MySqlCommand(); MySQLQuery.CommandText = "INSERT INTO `Chat_Message`(`FK_ID`,`Message`,`Sender_Name`,`Receiver_Status`,`Salt`,`Nonce`) VALUES (@FK_ID,@Message,@Sender_Name,@Receiver_Status,@Salt,@Nonce)"; MySQLQuery.Parameters.Add("@FK_ID", MySqlDbType.Text).Value = ID; MySQLQuery.Parameters.Add("@Message", MySqlDbType.Text).Value = MessageInt.ToString(); MySQLQuery.Parameters.Add("@Sender_Name", MySqlDbType.Text).Value = Current_User; MySQLQuery.Parameters.Add("@Receiver_Status", MySqlDbType.Text).Value = "Sent"; MySQLQuery.Parameters.Add("@Salt", MySqlDbType.Text).Value = SaltInt.ToString(); MySQLQuery.Parameters.Add("@Nonce", MySqlDbType.Text).Value = Nonce.ToString(); MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); MySQLQuery.ExecuteNonQuery(); MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); Determiner = 0; if (Determiner == 0 && ConfirmationTimer == null) { SetConfirmationTimer(); } } }