TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rooholah heydari
NA
12
1.1k
whats the problem in the running? rsa code
Oct 12 2016 10:09 AM
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
}
}
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
Reply
Answers (
5
)
Help me to find error and correct the code
how to consume wsdl web service using gsoap in c++