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

      

  • 相关阅读:
    魏新 20190912-1 每周例行报告
    魏新 20190912-2 命令行
    魏新 20180912-3 词频统计
    魏新 20190905-1 每周例行报告
    魏新 20190905-3 命令行和控制台编程
    魏新 20190905-2 博客作业
    20190911-例行报告
    肖亚男 20190910-2 博客作业
    宋晓丽20190919-5 代码规范,结对要求
    宋晓丽20190919-3 效能分析
  • 原文地址:https://www.cnblogs.com/wgscd/p/9663094.html
Copyright © 2011-2022 走看看