zoukankan      html  css  js  c++  java
  • C# Test Encryption and Decryption

     public MainWindow()
            {
              
                InitializeComponent();
                Title = getUUID();
                string s= httpGet("http://220.181.57.216/");
                //MessageBox.Show(s);
                MessageBox.Show( CheckSum("2019-9-10"));
                string sEncode=encode("0;2018-12-30");
                string sDecode=decode(sEncode );
                Title = sEncode +"-------"+ sDecode ;
    
    
            }
    
            int tabIndex = 0;
    
    
    
            string getUUID()
            {
                string code = null;
                SelectQuery query = new SelectQuery("select * from Win32_ComputerSystemProduct");
                using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
                {
    
                  //  MessageBox.Show(searcher.Get().Count.ToString());
                    foreach (var item in searcher.Get() )
                    {
                        using (item) code = item["UUID"].ToString();
    
                    }
                }
                return code;
    
    
            }
    
    
            public static string encode(string str)
            {
                string htext = "";
    
                for (int i = 0; i < str.Length; i++)
                {
                    htext = htext + (char)(str[i] + 22 );
                }
                return htext;
            }
    
            public static string decode(string str)
            {
                string dtext = "";
    
                for (int i = 0; i < str.Length; i++)
                {
                    dtext = dtext + (char)(str[i] - 22 );
                }
                return dtext;
            }
    
            private static string CheckSum(string message)
            {
                char[] chars = message.ToCharArray();
                int checksum = 0;
                for (int i = 0; i < chars.Length; i++)
                {
                    checksum += (int)chars[i];
                }
               //  checksum = (~checksum & 0xFFFF) + 0x0001;
                 //return Convert.ToString(checksum, 16).ToUpper();
                 return Convert.ToString(checksum, 10).ToUpper().PadLeft(5,'0');
            }
    

      

  • 相关阅读:
    c#数据类型
    遮罩层
    图片轮播
    js 获取浏览器高度和宽度值
    bootstrap、jquery
    洛谷P1442 铁球落地 题解
    HDU3016 Man Down 题解
    POJ2892 Tunnel Warfare 题解
    HDU2795 Billboard 题解
    CF920F SUM and REPLACE 题解
  • 原文地址:https://www.cnblogs.com/wgscd/p/9663094.html
Copyright © 2011-2022 走看看