- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Security.Cryptography;
- namespace RSAEncryption
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- #region-----Encryptionand Decryption Function-----
- static public byte[] Encryption(byte[] Data, RSAParameters RSAKey, bool DoOAEPPadding)
- {
- try
- {
- byte[] encryptedData;
- using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
- {
- RSA.ImportParameters(RSAKey);
- encryptedData = RSA.Encrypt(Data, DoOAEPPadding);
- }
- return encryptedData;
- }
- catch (CryptographicException e)
- {
- Console.WriteLine(e.Message);
- return null;
- }
- }
- static public byte[] Decryption(byte[] Data, RSAParameters RSAKey, bool DoOAEPPadding)
- {
- try
- {
- byte[] decryptedData;
- using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
- {
- RSA.ImportParameters(RSAKey);
- decryptedData = RSA.Decrypt(Data, DoOAEPPadding);
- }
- return decryptedData;
- }
- catch (CryptographicException e)
- {
- Console.WriteLine(e.ToString());
- return null;
- }
- }
- #endregion
- #region--variables area
- UnicodeEncoding ByteConverter = new UnicodeEncoding();
- RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
- byte[] plaintext;
- byte[] encryptedtext;
- #endregion
- #region-- Function Implemantation
- private void button1_Click(object sender, EventArgs e)
- {
- plaintext = ByteConverter.GetBytes(txtplain.Text);
- encryptedtext = Encryption(plaintext, RSA.ExportParameters(false), false);
- txtencrypt.Text = ByteConverter.GetString(encryptedtext);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- byte[] decryptedtex = Decryption(encryptedtext, RSA.ExportParameters(true), false);
- txtdecrypt.Text = ByteConverter.GetString(decryptedtex);
- }
- #endregion
- }
- }
Whats the problem in the running? rsa code
Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) E:\asli\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs 18 33 WindowsFormsApplication1

Suresh MRank #171 · 14K reputationPosted Oct 12, 2016, 10:44 PM EDT
Suresh MRank #171 · 14K reputationPosted Oct 12, 2016, 7:53 PM EDT
rooholah heydari11 reputationPosted Oct 12, 2016, 10:41 PM EDT
rooholah heydari11 reputationPosted Oct 12, 2016, 11:17 PM EDT