开发者

How to write decryption code in c# [closed]

开发者 https://www.devze.com 2023-03-29 11:01 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomp开发者_运维问答lete, overly broad, or rhetorical andcannot be reasonably answered in its current form.
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

精彩评论

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

关注公众号