使用ECC描述 我对这个文件的描述有问题,有人可以帮助我吗?我在这里使用ECC输入图像描述
代码在这里:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace eccdh_Forme.ECC
{
public class ECCDH
{
public static byte[] Enkripto(byte[] key, string MesazhiSekret)
{
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
key=aes.Key;
byte[] iv = aes.IV;
aes.BlockSize = 128;
aes.Mode = CipherMode.ECB;
aes.Padding = PaddingMode.PKCS7;
// Encrypt the message
using (MemoryStream ciphertext = new MemoryStream())
using (CryptoStream cs = new CryptoStream(ciphertext, aes.CreateEncryptor(), CryptoStreamMode.Write))
{
byte[] plaintextMessage = Encoding.UTF8.GetBytes(MesazhiSekret);
cs.Write(plaintextMessage, 0, plaintextMessage.Length);
cs.Close();
byte[] cipherMesazhi = ciphertext.ToArray();
return cipherMesazhi;
}
}
public static byte[] Dekripto(byte[] encryptedMessage, byte[] bobKey)//e shtuar e re mja pasu vleren
{
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
byte[] message;
bobKey=aes.Key;
byte[] iv = aes.IV;
// Decrypt the message
using (MemoryStream plaintext = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(plaintext, aes.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(encryptedMessage, 0, encryptedMessage.Length);
cs.Close();
message = plaintext.ToArray();
}
}
return message;
}
}
}
答案 0 :(得分:0)
这里存在许多问题,但是最有可能导致异常的问题是您向后分配密钥。这样:
Template. workflow.events({
"click .createbtnsub":function(event, template){
$(event.target).siblings('.due').find('.subcontent').show();
},
"click .cancelsub":function(event, template){
$(event.target).siblings('.due').find('.subcontent').hide();
}
});
您正在将参数值设置为随机AES密钥。你可能打算这样做:
AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
byte[] message;
bobKey=aes.Key;
byte[] iv = aes.IV;
其他事项: