- 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
this form with this code doesnt work . and this buttons dosent work in debugging. whats the problem?
Suresh MPosted Oct 13, 2016, 2:44 AM
rooholah heydariPosted Oct 13, 2016, 3:23 AM
rooholah heydariPosted Oct 13, 2016, 3:17 AM