jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
namespace HW.Utility
{
    using System;
    using System.Security.Cryptography;
    using System.Text;
 
    public class CryptographyUti
    {
        private string _key;
 
        public string Decrypt(string strEncrypted)
        {
            string str;
            try
            {
                str = Decrypt(strEncrypted, this._key);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return str;
        }
 
        public static string Decrypt(string strEncrypted, string strKey)
        {
            string str3;
            try
            {
                TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider();
                MD5CryptoServiceProvider provider2 = new MD5CryptoServiceProvider();
                string s = strKey;
                byte[] buffer = provider2.ComputeHash(Encoding.Unicode.GetBytes(s));
                provider2 = null;
                provider.Key = buffer;
                provider.Mode = CipherMode.ECB;
                byte[] inputBuffer = Convert.FromBase64String(strEncrypted);
                string str2 = Encoding.Unicode.GetString(provider.CreateDecryptor().TransformFinalBlock(inputBuffer, 0, inputBuffer.Length));
                provider = null;
                str3 = str2;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return str3;
        }
 
        public string Encrypt(string strToEncrypt)
        {
            string str;
            try
            {
                str = Encrypt(strToEncrypt, this._key);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return str;
        }
 
        public static string Encrypt(string strToEncrypt, string strKey)
        {
            string str2;
            try
            {
                TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider();
                MD5CryptoServiceProvider provider2 = new MD5CryptoServiceProvider();
                string s = strKey;
                byte[] buffer = provider2.ComputeHash(Encoding.Unicode.GetBytes(s));
                provider2 = null;
                provider.Key = buffer;
                provider.Mode = CipherMode.ECB;
                byte[] bytes = Encoding.Unicode.GetBytes(strToEncrypt);
                str2 = Convert.ToBase64String(provider.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length));
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return str2;
        }
 
        public string Key
        {
            set
            {
                this._key = value;
            }
        }
    }
}