Exemplo n.º 1
0
 private void BtnChangePassword_Click(object sender, EventArgs e)
 {
     if (!txtpass.Text.Equals("CONTRASEÑA"))
     {
         if (!txtpassconf.Text.Equals("CONFIRME LA CONTRASEÑA"))
         {
             //Comparamos que coincidan
             Console.WriteLine("CHANGEPASSWORD/Contraseña: '" + txtpass.Text + "' | Length: " + txtpass.TextLength);
             Console.WriteLine("CHANGEPASSWORD/CContraseña: '" + txtpassconf.Text + "' | Length: " + txtpassconf.TextLength);
             if (IsEqualsPass())
             {
                 // Create a new instance of the AesManaged
                 // class.  This generates a new key and initialization
                 // vector (IV).
                 using (AesManaged myAes = new AesManaged())
                 {
                     var rsa = new cryptography.SystemSupportRSA();
                     // Encrypt the string to an array of bytes.
                     byte[] cipherpass = rsa.EncryptStringToBytes_Aes(txtpass.Text, myAes.Key, myAes.IV);
                     byte[] ciphercode = rsa.EncryptStringToBytes_Aes(UserCache.UserCode, myAes.Key, myAes.IV);
                     userLog.UserUpdatePass(cipherpass, ciphercode, myAes.Key, myAes.IV);
                     UserCache.UserPass = rsa.GetMd5Hash(txtpass.Text);
                     Console.WriteLine("CHANGEPASSWORD/Actualizar a " + txtpass + "=" + UserCache.UserPass);
                     this.Close();
                 }
             }
             else
             {
                 MsgError("No coinciden las contraseñas");
             }
         }
         else
         {
             MsgError("Ingrese la confirmación de la nueva contraseña");
         }
     }
     else
     {
         MsgError("Ingrese la nueva contraseña");
     }
 }
Exemplo n.º 2
0
 private void BtnRecoveryAccount_Click(object sender, EventArgs e)
 {
     if (!txtAccount.Text.Equals("USUARIO O CORREO ELECTRÓNICO"))
     {
         if (!txtToken.Text.Equals("TOKEN"))
         {
             byte[] cipheraccount;
             byte[] ciphertoken;
             using (AesManaged myAes = new AesManaged())
             {
                 var rsa = new cryptography.SystemSupportRSA();
                 // Encrypt the string to an array of bytes.
                 cipheraccount = rsa.EncryptStringToBytes_Aes(txtAccount.Text, myAes.Key, myAes.IV);
                 ciphertoken   = rsa.EncryptStringToBytes_Aes(txtToken.Text, myAes.Key, myAes.IV);
                 var      request = userLog.UserRecoveryAccount(ciphertoken, cipheraccount, myAes.Key, myAes.IV);
                 string[] result  = request.Split(',');
                 if (result[0].Equals("s"))
                 {
                     MsgOk(result[1]);
                 }
                 else
                 {
                     MsgError(result[1]);
                 }
             }
         }
         else
         {
             MsgError("Ingrese el token de seguridad");
         }
     }
     else
     {
         MsgError("Ingrese usuario o cuenta de correo electrónico");
     }
 }