[問題] c#加密問題
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
namespace RSA_CRYPTO
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
UnicodeEncoding ByteConverter = new UnicodeEncoding();
byte[] encryptedData;
string testtext1;
testtext1 = textBox1.Text;
byte[] byteArray = System.Text.Encoding.Default.GetBytes(testtext1);//轉成byte
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
encryptedData = RSAEncrypt(byteArray, RSA.ExportParameters(false), false);
string str = System.Text.Encoding.GetString(encryptedData);//轉string
MessageBox.Show(str);
}
static public byte[] RSAEncrypt(byte[] DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding)
{
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
RSA.ImportParameters(RSAKeyInfo);
return RSA.Encrypt(DataToEncrypt, DoOAEPPadding);
}
private void label1_ParentChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
偵錯的結果:方法GetString 沒有任何多載使用"1"個引數
不知道問題出在哪~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.126.10.119
→
05/19 21:01, , 1F
05/19 21:01, 1F