Imports System
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Namespace APress.ProAspNet.Utility
Public NotInheritable Class AsymmetricEncryptionUtility
Private Sub New()
End Sub
Public Shared Function GenerateKey(ByVal targetFile As String) As String
Dim Algorithm As New RSACryptoServiceProvider()
' Save the private key
Dim CompleteKey As String = Algorithm.ToXmlString(True)
Dim KeyBytes As Byte() = Encoding.UTF8.GetBytes(CompleteKey)
KeyBytes = ProtectedData.Protect(KeyBytes, Nothing, DataProtectionScope.LocalMachine)
Using fs As New FileStream(targetFile, FileMode.Create)
fs.Write(KeyBytes, 0, KeyBytes.Length)
End Using
' Return the public key
Return Algorithm.ToXmlString(False)
End Function
Private Shared Sub ReadKey(ByVal algorith ...
Go to the complete details ...