星火微课系统客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.IO;
  3. using System.Security.Cryptography;
  4. using System.Text;
  5. namespace Common.system
  6. {
  7. public class DataProvider
  8. {
  9. ///3DES解密
  10. public static string TripleDESDecrypt(string pToDecrypt, string sKey)
  11. {
  12. sKey = sKey.Substring(0, 24);
  13. TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider
  14. {
  15. Mode = CipherMode.ECB,
  16. Padding = PaddingMode.Zeros
  17. };
  18. byte[] inputByteArray = new byte[pToDecrypt.Length / 2];
  19. for (int x = 0; x < pToDecrypt.Length / 2; x++)
  20. {
  21. int i = (Convert.ToInt32(pToDecrypt.Substring(x * 2, 2), 16));
  22. inputByteArray[x] = (byte)i;
  23. }
  24. des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
  25. des.IV = new byte[] { 0, 00, 00, 00, 00, 00, 00, 00, };
  26. MemoryStream ms = new MemoryStream();
  27. CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
  28. cs.Write(inputByteArray, 0, inputByteArray.Length);
  29. cs.FlushFinalBlock();
  30. StringBuilder ret = new StringBuilder();
  31. return System.Text.Encoding.Default.GetString(ms.ToArray()).Replace("\0", "");
  32. }
  33. /// <summary>
  34. /// 返回一个时间戳到秒
  35. /// </summary>
  36. /// <returns></returns>
  37. public static long TimestampTotalSeconds()
  38. {
  39. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  40. long timestr = Convert.ToInt64(ts.TotalSeconds);
  41. return timestr;
  42. }
  43. }
  44. }