1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00
ProxySU/ProxySuper.Core/Helpers/Utils.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2021-05-16 04:12:47 +03:00
using Newtonsoft.Json;
using System;
2021-05-15 11:45:36 +03:00
using System.Collections.Generic;
2021-05-16 04:12:47 +03:00
using System.IO;
2021-05-15 11:45:36 +03:00
using System.Linq;
2021-05-16 04:12:47 +03:00
using System.Runtime.Serialization.Formatters.Binary;
2021-05-15 11:45:36 +03:00
using System.Text;
using System.Threading.Tasks;
namespace ProxySuper.Core.Services
{
2021-05-16 04:12:47 +03:00
public class Utils
2021-05-15 11:45:36 +03:00
{
2021-05-16 04:12:47 +03:00
public static string Base64Encode(string plainText)
2021-05-15 11:45:36 +03:00
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
2021-05-16 04:12:47 +03:00
public static string Base64Decode(string base64EncodedData)
2021-05-15 11:45:36 +03:00
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
2021-05-16 04:12:47 +03:00
public static T DeepClone<T>(T obj) where T : class
{
var serialized = JsonConvert.SerializeObject(obj);
return JsonConvert.DeserializeObject<T>(serialized);
}
2021-05-25 13:28:37 +03:00
public static string GetTickID()
{
return DateTime.Now.Ticks.ToString();
}
2021-05-15 11:45:36 +03:00
}
}