Saturday, December 29, 2007

C#: Encode a string to Base64

public string EncodeStringToBase64(string toEncode)
{
byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
string returnValue = System.Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}

1 comment:

  1. hi , how to encode string to different type of string like if i want to convert , Yasir to kklkiuesdrre , then what should i do ?

    ReplyDelete

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.