troubleshooting Question

VB.NET AES Encryption

Avatar of eeyo
eeyo asked on
EncryptionVisual Basic.NET
9 Comments3 Solutions1473 ViewsLast Modified:
Sorry, encryption newbie here.  Can someone provide some feedback on this AES encryption algorithm?
        Public Shared Function SampleEncryptAES2Base64(ByVal dataToEncrypt As String, ByVal Password As String) As String
            Dim keyBytes As Byte() = UTF8Encoding.UTF8.GetBytes(Password) 
            Dim rfc As New Rfc2898DeriveBytes(Password, keyBytes, 1000)

            ' Use the AES managed encryption provider
            Dim encryptor As New AesManaged()
            encryptor.Key = rfc.GetBytes(16)
            encryptor.IV = rfc.GetBytes(16)

            Using ms As New MemoryStream()
                Using encrypt As New CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)
                    Dim dataBytes As Byte() = New UTF8Encoding(False).GetBytes(dataToEncrypt)
                    encrypt.Write(dataBytes, 0, dataBytes.Length)
                    Return Convert.ToBase64String(ms.ToArray())
                End Using
            End Using
        End Function

Open in new window

1) Is it possible to determine if this AES-128, 256 or 512?
2) Does the fact the encryptor.Key and encryptor.IV are the same make this less secure?

Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros