Exemplo n.º 1
0
        public void CryptoEncryptString_Throws_Error_When_Password_Is_Null()
        {
            //  Arrange
            Symmetric symmetric = new Symmetric();

            password = null;

            //  Act
            string encryptedString = symmetric.EncryptString(password, salt, encryptThis);
        }
Exemplo n.º 2
0
        public void CryptoEncryptString_Throws_Error_When_TextToEncrypt_Is_Empty_String()
        {
            //  Arrange
            Symmetric symmetric = new Symmetric();

            encryptThis = string.Empty;

            //  Act
            string encryptedString = symmetric.EncryptString(password, salt, encryptThis);
        }
Exemplo n.º 3
0
        public void CryptoEncryptString_Throws_Error_When_Salt_Is_Null()
        {
            //  Arrange
            Symmetric symmetric = new Symmetric();

            salt = null;

            //  Act
            string encryptedString = symmetric.EncryptString("bvgfiSdfr4)", salt, encryptThis);
        }
Exemplo n.º 4
0
        public void CryptoEncryptString_Encrypts_String()
        {
            //  Arrange
            Symmetric symmetric = new Symmetric();

            //  Act
            string encryptedString = symmetric.EncryptString(password, salt, encryptThis);

            //  Assert
            Assert.IsInstanceOfType(encryptedString, typeof(string));
            Assert.AreNotEqual(encryptedString, encryptThis);
        }
Exemplo n.º 5
0
 public void WriteString(string data, bool withEncrypt = false, string algorithm = "AES", string password = "******")
 {
     using (FileStream fs = new FileStream(this.FileName, FileMode.OpenOrCreate, FileAccess.Write))
         using (StreamWriter swr = new StreamWriter(fs))
         {
             if (withEncrypt)
             {
                 Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance(algorithm, password));
                 swr.Write(sym.EncryptString(data));
                 swr.Flush();
             }
             else
             {
                 swr.Write(data);
                 swr.Flush();
             }
         }
 }
Exemplo n.º 6
0
        private void btnEncryptRijndael_Click(object sender, EventArgs e)
        {
            Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance("Rijndael", "12345678"));

            txtEncrypted.Text = sym.EncryptString(txtPlainText.Text.Trim());
        }
Exemplo n.º 7
0
        private void btnEncryptAES_Click(object sender, EventArgs e)
        {
            Symmetric sym = new Symmetric(CryptoFactory.GetSymmetricInstance("AES", "tumsakal_0963189366"));

            txtEncrypted.Text = sym.EncryptString(txtPlainText.Text.Trim());
        }