ProcessBlock() public method

public ProcessBlock ( byte input, int inOff, int length ) : byte[]
input byte
inOff int
length int
return byte[]
コード例 #1
0
 public string Encrypt(byte[] dataToEncrypt)
 {
     var rsaKeyParameters = GetRsaKeyParameters();
     var rsaEngine = new Pkcs1Encoding(new RsaEngine());
     rsaEngine.Init(true, rsaKeyParameters);
     var encodedDataToEncrypt = new UTF8Encoding().GetBytes(Convert.ToBase64String(dataToEncrypt));
     return Convert.ToBase64String(rsaEngine.ProcessBlock(encodedDataToEncrypt, 0, encodedDataToEncrypt.Length));
 }
コード例 #2
0
 public static byte[] DecryptRsa(string encrypted, string privateKey)
 {
     var rsaKeyParameters = GetRsaKeyParameters(privateKey);
     var rsaEngine = new Pkcs1Encoding(new RsaEngine());
     rsaEngine.Init(false, rsaKeyParameters);
     var decoded = Convert.FromBase64String(encrypted);
     var decryptedEncodedBytes = rsaEngine.ProcessBlock(decoded, 0, decoded.Length);
     var decryptedEncodedString = new UTF8Encoding().GetString(decryptedEncodedBytes, 0, decryptedEncodedBytes.Length);
     return Convert.FromBase64String(decryptedEncodedString);
 }