hi,
i am very new to vb.net and just started learning from the sources on Internet. i m trying to create a base64 coded password but i m stuck on one of its lines.

I applied MD5 code to password then I want to apply base64 to password.

Dim MD5Hash As String = getMD5Hash(txtPassword.Text)

    Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(txtPassword.Text)

    Dim base64 As String = Convert.ToBase64String(byt)

    ' convert the byte array to a Base64 string
    [B]base64 [/B]= Convert.ToBase64String(byt)

this gave me a "Declaration expected" error for base64

What do I have to? How can I fix it?

This statement base64 = Convert.ToBase64String(byt) is placed outside the block/procedures. (Only declarations are allowed outside procedures.)

Sub Test()
        Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes("hello")

        Dim base64 As String = Convert.ToBase64String(byt)

        ' convert the byte array to a Base64 string
        base64 = Convert.ToBase64String(byt)
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.