Please Help coding this in Visual studio 2013!. Thank you in advance Your missio
ID: 3862787 • Letter: P
Question
Please Help coding this in Visual studio 2013!. Thank you in advance
Your mission is to design an "ENIGMA" program that will make it quick and easy for spies to encode and decode messages on the run, according to the RSA method. Your program should have a very friendly interface that is COMPLETELY self explanatory. Your RSA project will be graded as follows: The interface allows the user to enter n, e and a number to be encoded and on a button click displays the encoded number. The interface allows the user to enter n, d and a number to be decoded and on a button click displays the decoded number. Every time the user clicks a button, the program generates two new primes with 3 digits each and displays the two primes and the corresponding values of n, e and d.Explanation / Answer
Private Function Encrypt(Text As String) As String
Dim EncryptionKey As String = "nvsReddy"
Dim clearBytes As Byte() = Encoding.Unicode.GetBytes(Text)
Using encryptor As Aes = Aes.Create()
Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D, _
&H65, &H64, &H76, &H65, &H64, &H65, _
&H76})
encryptor.Key = pdb.GetBytes(32)
encryptor.IV = pdb.GetBytes(16)
Using ms As New MemoryStream()
Using cs As New CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)
cs.Write(clearBytes, 0, clearBytes.Length)
cs.Close()
End Using
Text = Convert.ToBase64String(ms.ToArray())
End Using
End Using
Return Text
End Function
Private Function Decrypt(cipherText As String) As String
Dim EncryptionKey As String = nvsReddy "
Dim cipherBytes As Byte() = Convert.FromBase64String(cipherText)
Using encryptor As Aes = Aes.Create()
Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D, _
&H65, &H64, &H76, &H65, &H64, &H65, _
&H76})
encryptor.Key = pdb.GetBytes(32)
encryptor.IV = pdb.GetBytes(16)
Using ms As New MemoryStream()
Using cs As New CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write)
cs.Write(cipherBytes, 0, cipherBytes.Length)
cs.Close()
End Using
cipherText = Encoding.Unicode.GetString(ms.ToArray())
End Using
End Using
Return cipherText
End Function