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');
            }
    

      

  • 相关阅读:
    ShaderLab 枚举常量
    PHP to .NET Compiler
    填充圆算法
    战争迷雾
    A*
    寻路算法
    Unity中将动画片段保存为文件
    令人蛋疼的错误提示 0xcdcdcdcd ,0xdddddddd ,0xfeeefeee ,0xcccccccc ,0xabababab
    2D光照
    Rider 2018 激活码
  • 原文地址:https://www.cnblogs.com/wgscd/p/9663094.html
Copyright © 2011-2022 走看看