Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you convert a string into base64 in .net framework 4

Tags:

string

vb.net

So I've been going around the internet looking for a way to convert regular text(string) into base64 string and found many solutions. I'm trying to use:

Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text)
TextBox2.Text = convert.ToBase64String(byt)

but it end up with an error saying

'ToBase64String' is not a member of 'System.Windows.Forms.Timer'.

What do I do to fix this? Or if there's a better way to code it please help.

like image 667
Mark Chai Avatar asked May 08 '12 17:05

Mark Chai


People also ask

How do you convert a string to Base64?

To convert a string into a Base64 character the following steps should be followed: Get the ASCII value of each character in the string. Compute the 8-bit binary equivalent of the ASCII values. Convert the 8-bit characters chunk into chunks of 6 bits by re-grouping the digits.

What is Base64 string in C#?

Base64 is an encoding method, where any data/images/audio file can be converted to binary data. And converted data can pass over the network without any data/image/audio loss.

How do I convert to Base64 in Windows?

If you are using a Windows system, there is no built-in command to directly perform Base64 encoding and decoding. But you can use the built-in command "certutil -encode/-decode" to indirectly perform Base64 encoding and decoding.


1 Answers

Use System.Convert.ToBase64String(byt). Otherwise the timer is picked up as the innermost matching name.
Not the best name for a timer btw.

like image 166
GSerg Avatar answered Oct 22 '22 17:10

GSerg