Encode and Decode in c# asp.net?

后端 未结 2 2108
后悔当初
后悔当初 2021-02-09 02:54

i am using Encoding and decoding :

For Encoding:

private string EncodeServerName(string ServerName)
    {
      byte[] NameEncodein = new byte[ServerName         


        
2条回答
  •  后悔当初
    2021-02-09 03:41

    Your code seems way too complex :-), here is one that works:

    public static string EncodeServerName(string serverName)
    {
        return Convert.ToBase64String(Encoding.UTF8.GetBytes(serverName));
    }
    
    public static string DecodeServerName(string encodedServername)
    {
        return Encoding.UTF8.GetString(Convert.FromBase64String(encodedServername));
    }
    

提交回复
热议问题