String to Base64 [C#]

string to base64

In this post we will look how to convert string to Base64 using C#. .Net provides .ToBase64String() method in System.Convert class that we can use to convert string to base64. It basically converts value of an array of 8-bit unsigned integers to its equivalent String representation consisting of base 64 digits.

Converting string to Base64 is bit tricky. We need to follow some steps mentioned as below

  • 1. We need to convert string to byte array.
  • 2. then we need to use Convert.ToBase64String() to convert byte array to base64 string.

Sample code to convert string to Base64 string [C#]


str ="How to convert string to nase64 in C#"; 
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(str);
// Now convert the byte array to a Base64 string
strBase64 = Convert.ToBase64String(byteArray);

14 comments :

  1. spot on with this write-up, i like the way you discuss the things. i'm impressed, i must say. i'll probably be back again to read more. thanks for sharing this with us.

    Lee Shin
    www.trendone.net

    ReplyDelete
  2. At last! I found this truly amazing article. I am very happy that I found this very good article of yours. Very good info and very creative post. Thanks.

    Jasmin
    www.imarksweb.org

    ReplyDelete

  3. When things get rough just stay calm and ask assistance from God and he'll give you peace. Visit my site for more information.

    triciajoy.com

    www.triciajoy.com

    ReplyDelete
  4. Love it! Very interesting topics, I hope the incoming comments and suggestion are equally positive. Thank you for sharing this information that is actually helpful.


    ufgop.org
    ufgop.org

    ReplyDelete
  5. I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


    edupdf.org

    ReplyDelete
  6. the primary execute is the transportation of products and it has to be done by the knowledgeable packers and moving companies Bangalore and also the near close relatives should be present here in managing items. Packers and Movers Pune
    Packers and Movers Bangalore
    Packers and Movers Delhi
    Packers and Movers Gurgaon

    ReplyDelete
  7. The important details on the Packers and Shifting companies Bangalore items is not easy procedure because you need the help of the packers and moving companies Bangalore for doing the procedure of moving Packers and Movers Chennai
    Packers and Movers Hyderabad
    Packers and Movers Mumbai
    Packers and Movers Noida

    ReplyDelete
  8. Every person has the passion in any aspects or things.
    If you love something and it came in front of you it completes your day and your mood turns into something you won't expected.
    I love your work and I want to read more about it. Visit my site if you have time . Thank you.

    triciajoy.com

    www.triciajoy.com

    ReplyDelete
  9. Hey there! Someone in my Myspace group shared this website with us so I came to check it out.I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!Terrific blog and fantastic design and style.

    www.gofastek.com

    ReplyDelete