开发者

How to write decryption code in c# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomp开发者_运维问答lete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

To encode a string

Code:

public string base64Encode(string data)
{
    try
    {
        byte[] encData_byte = new byte[data.Length];
        encData_byte = System.Text.Encoding.UTF8.GetBytes(data);    
        string encodedData = Convert.ToBase64String(encData_byte);
        return encodedData;
    }
    catch(Exception e)
    {
        throw new Exception("Error in base64Encode" + e.Message);
    }
}


public string Base64Decode(string data)
{
    byte[] byteArray = Convert.FromBase64String(data);
    var message = System.Text.Encoding.UTF8.GetString(byteArray);
    return message;
}


Have a look at Convert.FromBase64String.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜