标签:
在visual studio中写的c#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace test
{
class Class1
{
static void Main(string[] args)
{
Console.WriteLine("I am comming");
String source = "Test String";
String encryptData = Class1.Encrypt(source, "1234567812345678", "1234567812345678");
Console.WriteLine("=1==");
Console.WriteLine(encryptData);
Console.WriteLine("=2==");
String decryptData = Class1.Decrypt("2fbwW9+8vPId2/foafZq6Q==", "1234567812345678", "1234567812345678");
Console.WriteLine(decryptData);
Console.WriteLine("=3==");
Console.WriteLine("I will go out");
}
public static string Encrypt(string toEncrypt, string key, string iv)
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(key);
byte[] ivArray = UTF8Encoding.UTF8.GetBytes(iv);
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.IV = ivArray;
rDel.Mode = CipherMode.CBC;
rDel.Padding =