ustify"> { Гість :=new guest (Name, Rights) ;; Користувач :=split [3]. Trim ();=new defUser (Name, Rights, Password) ;; Адміністратор :=split [3]. Trim ();=new admin (Name, Rights, Password) ;;
}. addUserAfter (userN, userBefore);=userN;
}. Close ();
} (IOException err)
{. Show (err. Message);
}
}
# endregion
# region Метод showvoid show (DataGridView table)
{(this. head. Next!=null)
{tmp=this. head. Next; (tmp!=Null)
{(tmp. Info is admin). Rows. Add ( Адміністратор raquo ;, tmp. Info. Name, (tmp. Info as admin). Password, tmp. Info. Rights); if (tmp. Info is guest). Rows. Add ( Гість , tmp. Info. Name, raquo ;, tmp. Info. Rights); if (tmp. Info is defUser). Rows. Add ( Користувач raquo ;, tmp. Info. Name, (tmp. Info as defUser). Password, tmp. Info. Rights);=tmp. Next;
}
}
}
# endregion
# region Пошук пользователяuser search (string sName)
{(this. head. Next!=null)
{tmp=this. head. Next; (tmp!=Null)
{(tmp. Info. Name == sName) tmp. Info;=tmp. Next;
}
} null;
}
# endregion
# region Static Functions
/// lt; summary gt;
///Encrypts a string
/// lt;/summary gt;
/// lt; param name= plainText gt; Text to be encrypted lt;/param gt;
/// lt; param name= password gt; Password to encrypt with lt;/param gt;
/// lt; param name= salt gt; Salt to encrypt with lt;/param gt;
/// lt; param name= hashAlgorithm gt; Can be either SHA1 or MD5 lt;/param gt;
/// lt; param name= passwordIterations gt; Number of iterations to do lt;/param gt;
/// lt; param name= initialVector gt; Needs to be 16 ASCII characters long lt;/param gt;
/// lt; param name= keySize gt; Can be 128, 192, or 256 lt;/param gt;
/// lt; returns gt; An encrypted string lt;/returns gt; string Encrypt (string plainText, string password, salt= Kosher raquo ;, string hashAlgorithm= SHA1 , passwordIterations=2, string initialVector= OFRna73m * aze01xY , keySize=256)
{(string. IsNullOrEmpty (plainText)) raquo ;; [] initialVectorBytes=Encoding. ASCII. GetBytes (initialVector); [] saltValueBytes=Encoding. ASCII. GetBytes (salt); [] plainTextBytes=Encoding. UTF8. GetBytes (plainText); derivedPassword=new PasswordDeriveBytes (password, saltValueBytes, hashAlgorithm, passwordIterations); [] keyBytes=derivedPassword. GetBytes (keySize/8); symmetricKey=new RijndaelManaged () ;. Mode=CipherMode. CBC; [] cipherTextBytes=null; (ICryptoTransform encryptor=symmetricKey. CreateEncryptor (keyBytes, initialVectorBytes))
{(MemoryStream memStream=new MemoryStream ())
{(CryptoStream cryptoStream=new CryptoStream (memStream, encryptor, CryptoStreamMode. Write))
{. Write (plainTextBytes, 0, plainTextBytes. Length) ;. FlushFinalBlock ();=memStream. ToArray () ;. Close () ;. Close ();
}
}
}. Clear (); Convert. ToBase64String (cipherTextBytes);
}
/// lt; summary gt;
///Decrypts a string
/// lt;/summary gt;
/// lt; param name= cipherText gt; Text to be decrypted lt;/param gt;
/// lt; param name= password gt; Password to decrypt with lt;/param gt;
/// lt; param name= salt gt; Salt to decrypt with lt;/param gt;
/// lt; param name= hashAlgorithm gt; Can be either SHA1 or MD5 lt;/param gt;
/// lt; param name= passwordIterations gt; Number of iterations to do lt;/param gt;
/// lt; param name= initialVector gt; Needs to be 16 ASCII characters long lt;/param gt;
/// lt; param name= keySize gt; Can be 128, 192, or 256 lt;/param gt;
/// lt; returns gt; A decrypted string lt;/returns gt; string Decrypt (string cipherText, string password, salt= Kosher raquo ;, string hashAlgorithm= SHA1 , passwordIterations=2, string initialVector...