123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Management;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- namespace Uninpho.Tools
- {
- public class sqClass
- {
-
-
-
-
-
-
- public static string Encrypt(string targetValue, string key)
- {
-
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
-
- byte[] arr_key = Encoding.UTF8.GetBytes(key.Substring(0, 8));
-
-
- byte[] arr_str = Encoding.UTF8.GetBytes(targetValue);
- MemoryStream ms = new MemoryStream();
-
- CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(arr_key, arr_key), CryptoStreamMode.Write);
-
- cs.Write(arr_str, 0, arr_str.Length);
- cs.Close();
- string str_des = Convert.ToBase64String(ms.ToArray());
- return str_des;
- }
-
-
-
-
-
-
- public static string Decrypt(string targetValue, string key)
- {
-
- byte[] arr_key = Encoding.UTF8.GetBytes(key.Substring(0, 8));
- MemoryStream ms = new MemoryStream();
-
- byte[] arr_des = Convert.FromBase64String(targetValue);
-
- DESCryptoServiceProvider des = new DESCryptoServiceProvider();
- CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(arr_key, arr_key), CryptoStreamMode.Write);
- cs.Write(arr_des, 0, arr_des.Length);
- cs.FlushFinalBlock();
- cs.Close();
- return Encoding.UTF8.GetString(ms.ToArray());
- }
-
-
-
-
- public static string GetCpuID()
- {
- try
- {
-
- string cpuInfo = "";
- ManagementClass mc = new ManagementClass("Win32_Processor");
- ManagementObjectCollection moc = mc.GetInstances();
- foreach (ManagementObject mo in moc)
- {
- cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
- }
- moc = null;
- mc = null;
- return cpuInfo;
- }
- catch
- {
- return "unknow";
- }
- finally
- {
- }
- }
- }
- }
|