C# 單純字串BASE64 互換 + 時間(DateTime)相減取得總毫秒(ms)

C# 單純字串BASE64 互換 + 時間(DateTime)相減取得總毫秒(ms)

C# 單純字串BASE64 互換 + 時間(DateTime)相減取得總毫秒(ms)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Pause()
        {
            Console.Write("Press any key to continue...");
            Console.ReadKey(true);
        }
        static public String Base64_encode(String StrData)
        {
            //https://www.base64encode.net/
            String StrAns;
            StrAns = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(StrData));
            return StrAns;
        }
        static public String Base64_decode(String StrData)
        {
            //https://www.base64decode.net/
            String StrAns;
            byte[] data = System.Convert.FromBase64String(StrData);
            StrAns = System.Text.ASCIIEncoding.ASCII.GetString(data);
            return StrAns;
        }
        static void Main(string[] args)
        {
            DateTime date3 = new DateTime(2019, 07, 19, 17, 01, 09, 000);
            Console.WriteLine("Date with milliseconds: {0:MM/dd/yyyy HH:mm:ss.fff}",date3);
            Console.WriteLine("Date All milliseconds:{0}", (long)(date3 - new DateTime(1970, 01, 01, 0, 0, 0, 000)).TotalMilliseconds);
            Console.WriteLine("Base64_encode(tablename) -> {0}", Base64_encode("tablename"));
            Console.WriteLine("Base64_encode(user) -> {0}", Base64_encode("user"));
            Console.WriteLine("Base64_encode(car) -> {0}", Base64_encode("car"));
            Console.WriteLine("Base64_decode(dGFibGVuYW1l) -> {0}", Base64_decode("dGFibGVuYW1l"));
            Console.WriteLine("Base64_decode(dXNlcg==) -> {0}", Base64_decode("dXNlcg=="));
            Console.WriteLine("Base64_decode(Y2Fy) -> {0}", Base64_decode("Y2Fy"));
            Pause();
        }
    }
}

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *