Hello everyone
I am trying to create a simple application that allows to send and receive messages in a secure way, using rsa or another similar system.
I wrote this little code to see if it was possible to create a pair of keys (one public and one private), save them and use them again later.
I have read several post, but I can't find one that shows how I can use a pair of pre-generated keys to encode decode.
It can be Rsa or another similar algorithm.
I am trying to create a simple application that allows to send and receive messages in a secure way, using rsa or another similar system.
I wrote this little code to see if it was possible to create a pair of keys (one public and one private), save them and use them again later.
Simple Test:
Dim TextOri As String
Dim Encoded1, Encoded2 As String
Dim cBytes() As Byte
Dim Decoded As String
Dim PublicKey1, PrivateKey1 As String
Dim PublicKey2, PrivateKey2 As String
TextOri = "Hello World"
'Generate keys
k.GenerateKey
PublicKey1 = su.EncodeBase64(k.PublicKeyToBytes)
PrivateKey1 = su.EncodeBase64(k.PrivateKeyToBytes)
'Encode
Encoded1 = su.EncodeBase64(TextOri.GetBytes("UTF8"))
'Generate new keys
k.GenerateKey
PublicKey2 = su.EncodeBase64(k.PublicKeyToBytes)
PrivateKey2 = su.EncodeBase64(k.PrivateKeyToBytes)
'I try to use the first set of keys
k.PublicKeyFromBytes(PublicKey1.GetBytes("UTF8"))
k.PrivateKeyFromBytes(PrivateKey1.GetBytes("UTF8"))
'Encode
Encoded2 = su.EncodeBase64(TextOri.GetBytes("UTF8"))
I have read several post, but I can't find one that shows how I can use a pair of pre-generated keys to encode decode.
It can be Rsa or another similar algorithm.