Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was trying out the RSA encryption code, referring to some of the codes online, and I tried this

C#
var encryptedData = RSA.Encrypt(testDatabyte, publicKey)


but error came out mentioning that
C#
System.Security.Cryptography.RSA does not contain definition for Encrypt


I am using .NET framework 4.5.1. Can i know how should I proceed?

What I have tried:

-referred to msdn microsoft and tried to add assemblies like
System.Security.Cryptography.AsymmetricAlgorithm
System.Security.Cryptography.RSA
System.Security.Cryptography.RSACryptoServiceProvider
but all of them is a type not a namespace
-have check the .Net framework version in msdn, and it did mention it is supported
Posted
Updated 12-Mar-16 17:06pm

1 solution

you dont show us how you instanciate your 'RSA' object - it needs to be of type RSACryptoServiceProvider

I suggest you start here for a working example RSACryptoServiceProvider Class (System.Security.Cryptography)[^]

[edit] and please dont post the same question in more than one forum [/edit]
 
Share this answer
 
v2
Comments
HitsugayaHisagi 13-Mar-16 4:15am    
yes i initiated that way with
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048)
and yes that is the same link i referred to, but still thanks for the suggestion.
And no i only posted the Qs here in this forum. Not sure what is happening, hmm...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900