Uso RSA Cryptography provider...
il codice è questo:
codice:
' structure that holds the public/private key pair
Dim rsaParam As RSAParameters
' create an instance of the RSA cryptography provider
' at this point a new public/private key pair has been created
Dim CSPParam As CspParameters = New CspParameters()
CSPParam.Flags = CspProviderFlags.UseMachineKeyStore
Dim rsa As RSACryptoServiceProvider = New RSACryptoServiceProvider(CSPParam)
' get a byte array representing the first string
Dim byteInput As Byte() = New System.Text.UnicodeEncoding().GetBytes(pwda)
' encrypt the string using the provider and save the result to the byteEncrypted array
Dim byteEncrypted As Byte() = rsa.Encrypt(byteInput, False)
' the rsaParam structure contains the public/private key pair.
' by passing true to ExportParameters, we tell the provider to include the private key
rsaParam = rsa.ExportParameters(True)
' for illustration purposes show the encrypted string in the second textbox
' this string should not be readable.
pwdencry = (New System.Text.UnicodeEncoding()).GetString(byteEncrypted)
ciau
Cl@