According to the video, I found it is relate to encrypt/decrypt. Here are some good articles about it, they all include sample, you could refer to them:
If you have any further questions, please feel free to post in this forum.
Best Regards,
Dillion
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
I have found a working C# code
here and I needed it in VB.NET. I was able to successfully convert it ias below. I tested for number s from 1 to 1 million.
Public Function EncryptData(ByVal Message As String, ByVal passphrase As String) As String
Dim Results() As Byte = Nothing
Dim UTF8 As System.Text.UTF8Encoding = New System.Text.UTF8Encoding()
Dim HashProvider As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim TDESKey() As Byte = HashProvider.ComputeHash(UTF8.GetBytes(passphrase))
Dim TDESAlgorithm As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
TDESAlgorithm.Key = TDESKey
TDESAlgorithm.Mode = CipherMode.ECB
TDESAlgorithm.Padding = PaddingMode.PKCS7
Dim DataToEncrypt() As Byte = UTF8.GetBytes(Message)
Try
Dim Encryptor As ICryptoTransform = TDESAlgorithm.CreateEncryptor
Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length)
Catch ex As Exception
Console.WriteLine(ex.ToString)
Finally
TDESAlgorithm.Clear()
HashProvider.Clear()
End Try
Return Convert.ToBase64String(Results)
End Function
Public Function DecryptData(ByVal Message As String, ByVal passphrase As String) As String
Dim Results() As Byte = Nothing
Dim UTF8 As System.Text.UTF8Encoding = New System.Text.UTF8Encoding()
Dim HashProvider As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim TDESKey() As Byte = HashProvider.ComputeHash(UTF8.GetBytes(passphrase))
Dim TDESAlgorithm As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
TDESAlgorithm.Key = TDESKey
TDESAlgorithm.Mode = CipherMode.ECB
TDESAlgorithm.Padding = PaddingMode.PKCS7
Dim DataToDecrypt() As Byte = Convert.FromBase64String(Message)
Try
Dim Decryptor As ICryptoTransform = TDESAlgorithm.CreateDecryptor
Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length)
Catch ex As Exception
Console.WriteLine(ex.ToString)
Finally
TDESAlgorithm.Clear()
HashProvider.Clear()
End Try
Return UTF8.GetString(Results)
End Function
Member
15 Points
47 Posts
Where do I download code mentioned in Q 11 - Explain how to encrypt/decrypt a string in .Net
Aug 27, 2014 03:42 PM|piyush_varma|LINK
Where can I download the code for the above question found in http://www.microsoftvirtualacademy.com/Content/ViewContent.aspx?et=8464&m=8454&ct=28532 please?
Thank you.
All-Star
45489 Points
7008 Posts
Microsoft
Re: Where do I download code mentioned in Q 11 - Explain how to encrypt/decrypt a string in .Net
Aug 29, 2014 08:20 AM|Zhi Lv - MSFT|LINK
Hi piyush_varma,
According to the video, I found it is relate to encrypt/decrypt. Here are some good articles about it, they all include sample, you could refer to them:
The MD5 hash algorithm: http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5(v=vs.110).aspx
Advanced Encryption Standard (AES): http://msdn.microsoft.com/en-us/library/system.security.cryptography.aes(v=vs.110).aspx
The Data Encryption Standard (DES) algorithm: http://msdn.microsoft.com/en-us/library/system.security.cryptography.des(v=vs.110).aspx
More details about cryptographic services, please refer to the following links:
http://msdn.microsoft.com/en-us/library/system.security.cryptography(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/92f9ye3s(v=vs.110).aspx
If you have any further questions, please feel free to post in this forum.
Best Regards,
Dillion
Member
15 Points
47 Posts
Re: Where do I download code mentioned in Q 11 - Explain how to encrypt/decrypt a string in .Net
Aug 29, 2014 06:38 PM|piyush_varma|LINK
I have found a working C# code here and I needed it in VB.NET. I was able to successfully convert it ias below. I tested for number s from 1 to 1 million.
Cryptography