troubleshooting Question

VB.NET AES Encryption

Avatar of eeyo
eeyo asked on
Visual Basic.NETEncryption
9 Comments1 Solution1473 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)
                    encrypt.FlushFinalBlock()
                    encrypt.Close()
                    Return Convert.ToBase64String(ms.ToArray())
                End Using
            End Using
        End Function
Specifically:
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?

Thanks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
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 1 Answer 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