├── AES.cs
├── BouncyCastle.Crypto.dll
├── DES.cs
├── Decoder.cs
├── Encoder.cs
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── RCoder.csproj
├── README.md
├── RSA.cs
├── Rc4.cs
├── app.config
├── form.Designer.cs
├── form.cs
├── form.resx
├── img
├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
└── 5.jpg
└── rcoder.ico
/AES.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace RCoder
10 | {
11 | class AES
12 | {
13 | //
14 | /// AES 加密
15 | ///
16 | /// 明文(待加密)
17 | /// 密文
18 | ///
19 | public string Encrypt(string str, string key)
20 | {
21 | if (string.IsNullOrEmpty(str)) return null;
22 | Byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
23 |
24 | RijndaelManaged rm = new RijndaelManaged
25 | {
26 | Key = Encoding.UTF8.GetBytes(key),
27 | Mode = CipherMode.ECB,
28 | Padding = PaddingMode.PKCS7
29 | };
30 |
31 | ICryptoTransform cTransform = rm.CreateEncryptor();
32 | Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
33 |
34 | return Convert.ToBase64String(resultArray, 0, resultArray.Length);
35 | }
36 |
37 | ///
38 | /// AES 解密
39 | ///
40 | /// 明文(待解密)
41 | /// 密文
42 | ///
43 | public string Decrypt(string str, string key)
44 | {
45 | if (string.IsNullOrEmpty(str)) return null;
46 | Byte[] toEncryptArray = Convert.FromBase64String(str);
47 |
48 | RijndaelManaged rm = new RijndaelManaged
49 | {
50 | Key = Encoding.UTF8.GetBytes(key),
51 | Mode = CipherMode.ECB,
52 | Padding = PaddingMode.PKCS7
53 | };
54 |
55 | ICryptoTransform cTransform = rm.CreateDecryptor();
56 | Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
57 |
58 | return Encoding.UTF8.GetString(resultArray);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/BouncyCastle.Crypto.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/BouncyCastle.Crypto.dll
--------------------------------------------------------------------------------
/DES.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace RCoder
10 | {
11 | class DES
12 | {
13 | public string Encrypt(string stringToEncrypt, string sKey)
14 | {
15 | DESCryptoServiceProvider des = new DESCryptoServiceProvider();
16 | byte[] inputByteArray = Encoding.GetEncoding("UTF-8").GetBytes(stringToEncrypt);
17 | des.Key = ASCIIEncoding.UTF8.GetBytes(sKey);
18 | des.IV = ASCIIEncoding.UTF8.GetBytes(sKey);
19 | MemoryStream ms = new MemoryStream();
20 | CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
21 | cs.Write(inputByteArray, 0, inputByteArray.Length);
22 | cs.FlushFinalBlock();
23 | StringBuilder ret = new StringBuilder();
24 | foreach (byte b in ms.ToArray())
25 | {
26 | ret.AppendFormat("{0:X2}", b);
27 | }
28 | ret.ToString();
29 | return ret.ToString();
30 | }
31 |
32 |
33 | public string Decrypt(string stringToDecrypt, string sKey)
34 | {
35 | DESCryptoServiceProvider des = new DESCryptoServiceProvider();
36 | byte[] inputByteArray = new byte[stringToDecrypt.Length / 2];
37 | for (int x = 0; x < stringToDecrypt.Length / 2; x++)
38 | {
39 | int i = (Convert.ToInt32(stringToDecrypt.Substring(x * 2, 2), 16));
40 | inputByteArray[x] = (byte)i;
41 | }
42 | des.Key = ASCIIEncoding.UTF8.GetBytes(sKey);
43 | des.IV = ASCIIEncoding.UTF8.GetBytes(sKey);
44 | MemoryStream ms = new MemoryStream();
45 | CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
46 | cs.Write(inputByteArray, 0, inputByteArray.Length);
47 | cs.FlushFinalBlock();
48 | StringBuilder ret = new StringBuilder();
49 | return Encoding.Default.GetString(ms.ToArray());
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Decoder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace RCoder
8 | {
9 | class Decoder
10 | {
11 | public string Rbase64(string code)
12 | {
13 | string decode = "";
14 | byte[] bytes = Convert.FromBase64String(code);
15 | try
16 | {
17 | decode = Encoding.GetEncoding("utf-8").GetString(bytes);
18 | }
19 | catch
20 | {
21 | decode = code;
22 | }
23 | return decode;
24 | }
25 | public string Rurl(string text)
26 | {
27 | string urlDecode = System.Web.HttpUtility.UrlDecode(text);
28 | return urlDecode;
29 | }
30 |
31 | public string Rhex(string mHex)
32 | {
33 | //if (mHex.Length <= 0) return "";
34 | byte[] vBytes = new byte[mHex.Length / 2];
35 | for (int i = 0; i < mHex.Length; i += 2)
36 | if (!byte.TryParse(mHex.Substring(i, 2), NumberStyles.HexNumber, null, out vBytes[i / 2]))
37 | vBytes[i / 2] = 0;
38 | return ASCIIEncoding.Default.GetString(vBytes);
39 | }
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Encoder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 |
7 | namespace RCoder
8 | {
9 | class Encoder
10 | {
11 | public string Rmd5_16(string strPwd)
12 | {
13 |
14 | MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
15 | string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(strPwd)), 4, 8);
16 | t2 = t2.Replace("-", "");
17 | return t2.ToUpper();
18 | }
19 |
20 | public string Rmd5_32(string txt)
21 | {
22 | using (MD5 mi = MD5.Create())
23 | {
24 | byte[] buffer = Encoding.Default.GetBytes(txt);
25 | //开始加密
26 | byte[] newBuffer = mi.ComputeHash(buffer);
27 | StringBuilder sb = new StringBuilder();
28 | for (int i = 0; i < newBuffer.Length; i++)
29 | {
30 | sb.Append(newBuffer[i].ToString("x2"));
31 | }
32 | return sb.ToString().ToUpper();
33 | }
34 |
35 | }
36 |
37 | public string Rbase64(string code)
38 | {
39 | string encode = "";
40 | byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
41 | try
42 | {
43 | encode = Convert.ToBase64String(bytes);
44 | }
45 | catch
46 | {
47 | encode = code;
48 | }
49 | return encode;
50 | }
51 |
52 | public string Rurl(string text)
53 | {
54 | string urlEncode = System.Web.HttpUtility.UrlEncode(text);
55 | return urlEncode;
56 | }
57 |
58 | public string Rhex(string text)
59 | {
60 |
61 | return BitConverter.ToString(ASCIIEncoding.Default.GetBytes(text)).Replace("-", "");
62 | }
63 |
64 |
65 | public string Rsha1(string str)
66 | {
67 | var buffer = Encoding.UTF8.GetBytes(str);
68 | var data = SHA1.Create().ComputeHash(buffer);
69 |
70 | var sb = new StringBuilder();
71 | foreach (var t in data)
72 | {
73 | sb.Append(t.ToString("X2"));
74 | }
75 | return sb.ToString();
76 | }
77 |
78 | public string Rsha256(string str)
79 | {
80 | var buffer = Encoding.UTF8.GetBytes(str);
81 | var data = SHA256.Create().ComputeHash(buffer);
82 |
83 | var sb = new StringBuilder();
84 | foreach (var t in data)
85 | {
86 | sb.Append(t.ToString("X2"));
87 | }
88 | return sb.ToString();
89 | }
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace RCoder
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// 应用程序的主入口点。
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new form());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("RCoder")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("RCoder")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("c9c57b6a-4334-46cb-9b28-d936361e0ff0")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace RCoder.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RCoder.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace RCoder.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/RCoder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {C9C57B6A-4334-46CB-9B28-D936361E0FF0}
8 | WinExe
9 | RCoder
10 | RCoder
11 | v4.0
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | false
36 |
37 |
38 | rcoder.ico
39 |
40 |
41 |
42 | ..\..\..\..\Downloads\bccrypto-csharp-1.8.2-bin\BouncyCastle.Crypto.dll
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Form
65 |
66 |
67 | form.cs
68 |
69 |
70 |
71 |
72 | form.cs
73 |
74 |
75 | ResXFileCodeGenerator
76 | Resources.Designer.cs
77 | Designer
78 |
79 |
80 | True
81 | Resources.resx
82 | True
83 |
84 |
85 |
86 | SettingsSingleFileGenerator
87 | Settings.Designer.cs
88 |
89 |
90 | True
91 | Settings.settings
92 | True
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Rcoder
2 | 基于渗透需求的万能编码器,随需求增加持续维护
3 |
4 |

5 |
6 | 
7 |
8 | 
9 |
10 | 
11 |
12 | 
13 |
--------------------------------------------------------------------------------
/RSA.cs:
--------------------------------------------------------------------------------
1 | using Org.BouncyCastle.Asn1;
2 | using Org.BouncyCastle.Asn1.Pkcs;
3 | using Org.BouncyCastle.Asn1.X509;
4 | using Org.BouncyCastle.Crypto;
5 | using Org.BouncyCastle.Crypto.Encodings;
6 | using Org.BouncyCastle.Crypto.Engines;
7 | using Org.BouncyCastle.Crypto.Generators;
8 | using Org.BouncyCastle.Crypto.Parameters;
9 | using Org.BouncyCastle.Pkcs;
10 | using Org.BouncyCastle.Security;
11 | using Org.BouncyCastle.X509;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.Linq;
15 | using System.Security.Cryptography;
16 | using System.Text;
17 |
18 | namespace RCoder
19 | {
20 | class RSA
21 | {
22 | private static Encoding Encoding_UTF8 = Encoding.UTF8;
23 |
24 | private AsymmetricKeyParameter GetPublicKeyParameter(string keyBase64)
25 | {
26 | keyBase64 = keyBase64.Replace("\r", "").Replace("\n", "").Replace(" ", "");
27 | byte[] publicInfoByte = Convert.FromBase64String(keyBase64);
28 | AsymmetricKeyParameter pubKey = PublicKeyFactory.CreateKey(publicInfoByte);
29 | return pubKey;
30 | }
31 |
32 | private AsymmetricKeyParameter GetPrivateKeyParameter(string keyBase64)
33 | {
34 | keyBase64 = keyBase64.Replace("\r", "").Replace("\n", "").Replace(" ", "");
35 | byte[] privateInfoByte = Convert.FromBase64String(keyBase64);
36 | AsymmetricKeyParameter priKey = PrivateKeyFactory.CreateKey(privateInfoByte);
37 | return priKey;
38 | }
39 |
40 |
41 |
42 |
43 | public string[] GetKeys()
44 | {
45 | string[] RSAKey = new String[2];
46 | RSAKEY key=GetKey();
47 | RSAKey[0] = "-----BEGIN PRIVATE KEY-----\r\n" + key.PrivateKey + "\r\n-----END PRIVATE KEY-----";
48 | RSAKey[1] = "-----BEGIN PUBLIC KEY-----\r\n" + key.PublicKey + "\r\n-----END PUBLIC KEY-----";
49 | return RSAKey;
50 | }
51 |
52 | public struct RSAKEY
53 | {
54 | public string PublicKey
55 | {
56 | get;
57 | set;
58 | }
59 | public string PrivateKey
60 | {
61 | get;
62 | set;
63 | }
64 | }
65 |
66 | public RSAKEY GetKey()
67 | {
68 | //RSA密钥对的构造器
69 | RsaKeyPairGenerator keyGenerator = new RsaKeyPairGenerator();
70 |
71 | //RSA密钥构造器的参数
72 | RsaKeyGenerationParameters param = new RsaKeyGenerationParameters(
73 | Org.BouncyCastle.Math.BigInteger.ValueOf(3),
74 | new Org.BouncyCastle.Security.SecureRandom(),
75 | 1024, //密钥长度
76 | 25);
77 | //用参数初始化密钥构造器
78 | keyGenerator.Init(param);
79 | //产生密钥对
80 | AsymmetricCipherKeyPair keyPair = keyGenerator.GenerateKeyPair();
81 | //获取公钥和密钥
82 | AsymmetricKeyParameter publicKey = keyPair.Public;
83 | AsymmetricKeyParameter privateKey = keyPair.Private;
84 |
85 | SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
86 | PrivateKeyInfo privateKeyInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(privateKey);
87 |
88 |
89 | Asn1Object asn1ObjectPublic = subjectPublicKeyInfo.ToAsn1Object();
90 |
91 | byte[] publicInfoByte = asn1ObjectPublic.GetEncoded("UTF-8");
92 | Asn1Object asn1ObjectPrivate = privateKeyInfo.ToAsn1Object();
93 | byte[] privateInfoByte = asn1ObjectPrivate.GetEncoded("UTF-8");
94 |
95 | RSAKEY item = new RSAKEY()
96 | {
97 | PublicKey = Convert.ToBase64String(publicInfoByte),
98 | PrivateKey = Convert.ToBase64String(privateInfoByte)
99 | };
100 |
101 | return item;
102 | }
103 |
104 |
105 |
106 | public string Encrypt(string data, string publicKey)
107 | {
108 | //非对称加密算法,加解密用
109 | IAsymmetricBlockCipher engine = new Pkcs1Encoding(new RsaEngine());
110 |
111 | //加密
112 |
113 | engine.Init(true, GetPublicKeyParameter(publicKey.Replace("-----BEGIN PUBLIC KEY-----\r\n", "").Replace("\r\n-----END PUBLIC KEY-----", "")));
114 | byte[] byteData = Encoding_UTF8.GetBytes(data);
115 | var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
116 | return Convert.ToBase64String(ResultData);
117 |
118 |
119 | }
120 |
121 |
122 | public string Decrypt(String data, string privateKey)
123 | {
124 | data = data.Replace("\r", "").Replace("\n", "").Replace(" ", "");
125 | //非对称加密算法,加解密用
126 | IAsymmetricBlockCipher engine = new Pkcs1Encoding(new RsaEngine());
127 |
128 | //解密
129 | try
130 | {
131 | engine.Init(false, GetPrivateKeyParameter(privateKey.Replace("-----BEGIN PRIVATE KEY-----\r\n", "").Replace("\r\n-----END PRIVATE KEY-----", "")));
132 | byte[] byteData = Convert.FromBase64String(data);
133 | var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
134 | return Encoding_UTF8.GetString(ResultData);
135 | }
136 | catch (Exception ex)
137 | {
138 | throw ex;
139 | }
140 | }
141 |
142 |
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/Rc4.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace RCoder
7 | {
8 | public class RC4
9 | {
10 | public string Encrypt(string key, string data)
11 | {
12 | return Convert.ToBase64String(Encrypt(Encoding.UTF8.GetBytes(key), Encoding.UTF8.GetBytes(data)));
13 | }
14 |
15 | public string Decrypt(string key, string data)
16 | {
17 | return Encoding.UTF8.GetString(Encrypt(Encoding.UTF8.GetBytes(key), Convert.FromBase64String(data)));
18 | }
19 |
20 | public static byte[] Encrypt(byte[] key, byte[] data)
21 | {
22 | return EncryptOutput(key, data).ToArray();
23 | }
24 |
25 | public static byte[] Decrypt(byte[] key, byte[] data)
26 | {
27 | return EncryptOutput(key, data).ToArray();
28 | }
29 |
30 | private static byte[] EncryptInitalize(byte[] key)
31 | {
32 | byte[] s = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
33 |
34 | for (int i = 0, j = 0; i < 256; i++)
35 | {
36 | j = (j + key[i % key.Length] + s[i]) & 255;
37 |
38 | Swap(s, i, j);
39 | }
40 |
41 | return s;
42 | }
43 |
44 | private static IEnumerable EncryptOutput(byte[] key, IEnumerable data)
45 | {
46 | byte[] s = EncryptInitalize(key);
47 |
48 | int i = 0;
49 | int j = 0;
50 |
51 | return data.Select((b) =>
52 | {
53 | i = (i + 1) & 255;
54 | j = (j + s[i]) & 255;
55 |
56 | Swap(s, i, j);
57 |
58 | return (byte)(b ^ s[(s[i] + s[j]) & 255]);
59 | });
60 | }
61 |
62 | private static void Swap(byte[] s, int i, int j)
63 | {
64 | byte c = s[i];
65 |
66 | s[i] = s[j];
67 | s[j] = c;
68 | }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/form.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace RCoder
4 | {
5 | partial class form
6 | {
7 | ///
8 | /// 必需的设计器变量。
9 | ///
10 | private System.ComponentModel.IContainer components = null;
11 |
12 | ///
13 | /// 清理所有正在使用的资源。
14 | ///
15 | /// 如果应释放托管资源,为 true;否则为 false。
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | base.Dispose(disposing);
23 | }
24 |
25 | #region Windows 窗体设计器生成的代码
26 |
27 | ///
28 | /// 设计器支持所需的方法 - 不要修改
29 | /// 使用代码编辑器修改此方法的内容。
30 | ///
31 | private void InitializeComponent()
32 | {
33 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(form));
34 | this.textBox1 = new System.Windows.Forms.TextBox();
35 | this.button1 = new System.Windows.Forms.Button();
36 | this.label1 = new System.Windows.Forms.Label();
37 | this.label2 = new System.Windows.Forms.Label();
38 | this.textBox2 = new System.Windows.Forms.TextBox();
39 | this.label3 = new System.Windows.Forms.Label();
40 | this.textBox3 = new System.Windows.Forms.TextBox();
41 | this.label4 = new System.Windows.Forms.Label();
42 | this.textBox4 = new System.Windows.Forms.TextBox();
43 | this.label5 = new System.Windows.Forms.Label();
44 | this.textBox5 = new System.Windows.Forms.TextBox();
45 | this.label6 = new System.Windows.Forms.Label();
46 | this.textBox6 = new System.Windows.Forms.TextBox();
47 | this.label7 = new System.Windows.Forms.Label();
48 | this.textBox7 = new System.Windows.Forms.TextBox();
49 | this.button2 = new System.Windows.Forms.Button();
50 | this.button3 = new System.Windows.Forms.Button();
51 | this.panel1 = new System.Windows.Forms.Panel();
52 | this.label8 = new System.Windows.Forms.Label();
53 | this.textBox8 = new System.Windows.Forms.TextBox();
54 | this.button5 = new System.Windows.Forms.Button();
55 | this.panel2 = new System.Windows.Forms.Panel();
56 | this.textBox16 = new System.Windows.Forms.TextBox();
57 | this.button7 = new System.Windows.Forms.Button();
58 | this.label10 = new System.Windows.Forms.Label();
59 | this.comboBox1 = new System.Windows.Forms.ComboBox();
60 | this.label9 = new System.Windows.Forms.Label();
61 | this.textBox9 = new System.Windows.Forms.TextBox();
62 | this.textBox12 = new System.Windows.Forms.TextBox();
63 | this.label12 = new System.Windows.Forms.Label();
64 | this.panel3 = new System.Windows.Forms.Panel();
65 | this.button8 = new System.Windows.Forms.Button();
66 | this.label15 = new System.Windows.Forms.Label();
67 | this.textBox13 = new System.Windows.Forms.TextBox();
68 | this.button6 = new System.Windows.Forms.Button();
69 | this.label11 = new System.Windows.Forms.Label();
70 | this.comboBox2 = new System.Windows.Forms.ComboBox();
71 | this.label13 = new System.Windows.Forms.Label();
72 | this.textBox10 = new System.Windows.Forms.TextBox();
73 | this.textBox11 = new System.Windows.Forms.TextBox();
74 | this.label14 = new System.Windows.Forms.Label();
75 | this.button4 = new System.Windows.Forms.Button();
76 | this.panel4 = new System.Windows.Forms.Panel();
77 | this.button11 = new System.Windows.Forms.Button();
78 | this.label22 = new System.Windows.Forms.Label();
79 | this.textBox19 = new System.Windows.Forms.TextBox();
80 | this.button10 = new System.Windows.Forms.Button();
81 | this.label18 = new System.Windows.Forms.Label();
82 | this.label21 = new System.Windows.Forms.Label();
83 | this.textBox15 = new System.Windows.Forms.TextBox();
84 | this.textBox18 = new System.Windows.Forms.TextBox();
85 | this.label20 = new System.Windows.Forms.Label();
86 | this.label19 = new System.Windows.Forms.Label();
87 | this.textBox17 = new System.Windows.Forms.TextBox();
88 | this.button9 = new System.Windows.Forms.Button();
89 | this.label16 = new System.Windows.Forms.Label();
90 | this.comboBox3 = new System.Windows.Forms.ComboBox();
91 | this.textBox14 = new System.Windows.Forms.TextBox();
92 | this.panel1.SuspendLayout();
93 | this.panel2.SuspendLayout();
94 | this.panel3.SuspendLayout();
95 | this.panel4.SuspendLayout();
96 | this.SuspendLayout();
97 | //
98 | // textBox1
99 | //
100 | this.textBox1.Location = new System.Drawing.Point(135, 168);
101 | this.textBox1.Name = "textBox1";
102 | this.textBox1.Size = new System.Drawing.Size(465, 28);
103 | this.textBox1.TabIndex = 0;
104 | //
105 | // button1
106 | //
107 | this.button1.Location = new System.Drawing.Point(97, 50);
108 | this.button1.Name = "button1";
109 | this.button1.Size = new System.Drawing.Size(145, 84);
110 | this.button1.TabIndex = 1;
111 | this.button1.Text = "加密 编码";
112 | this.button1.UseVisualStyleBackColor = true;
113 | this.button1.Click += new System.EventHandler(this.button1_Click);
114 | //
115 | // label1
116 | //
117 | this.label1.AutoSize = true;
118 | this.label1.Location = new System.Drawing.Point(58, 177);
119 | this.label1.Name = "label1";
120 | this.label1.Size = new System.Drawing.Size(62, 18);
121 | this.label1.TabIndex = 2;
122 | this.label1.Text = "MD5_16";
123 | //
124 | // label2
125 | //
126 | this.label2.AutoSize = true;
127 | this.label2.Location = new System.Drawing.Point(58, 233);
128 | this.label2.Name = "label2";
129 | this.label2.Size = new System.Drawing.Size(62, 18);
130 | this.label2.TabIndex = 4;
131 | this.label2.Text = "MD5_32";
132 | //
133 | // textBox2
134 | //
135 | this.textBox2.Location = new System.Drawing.Point(135, 224);
136 | this.textBox2.Name = "textBox2";
137 | this.textBox2.Size = new System.Drawing.Size(465, 28);
138 | this.textBox2.TabIndex = 3;
139 | //
140 | // label3
141 | //
142 | this.label3.AutoSize = true;
143 | this.label3.Location = new System.Drawing.Point(58, 412);
144 | this.label3.Name = "label3";
145 | this.label3.Size = new System.Drawing.Size(35, 18);
146 | this.label3.TabIndex = 6;
147 | this.label3.Text = "URL";
148 | //
149 | // textBox3
150 | //
151 | this.textBox3.Location = new System.Drawing.Point(135, 403);
152 | this.textBox3.Name = "textBox3";
153 | this.textBox3.Size = new System.Drawing.Size(465, 28);
154 | this.textBox3.TabIndex = 5;
155 | //
156 | // label4
157 | //
158 | this.label4.AutoSize = true;
159 | this.label4.Location = new System.Drawing.Point(58, 471);
160 | this.label4.Name = "label4";
161 | this.label4.Size = new System.Drawing.Size(62, 18);
162 | this.label4.TabIndex = 8;
163 | this.label4.Text = "BASE64";
164 | //
165 | // textBox4
166 | //
167 | this.textBox4.Location = new System.Drawing.Point(135, 462);
168 | this.textBox4.Name = "textBox4";
169 | this.textBox4.Size = new System.Drawing.Size(465, 28);
170 | this.textBox4.TabIndex = 7;
171 | //
172 | // label5
173 | //
174 | this.label5.AutoSize = true;
175 | this.label5.Location = new System.Drawing.Point(58, 529);
176 | this.label5.Name = "label5";
177 | this.label5.Size = new System.Drawing.Size(35, 18);
178 | this.label5.TabIndex = 10;
179 | this.label5.Text = "HEX";
180 | //
181 | // textBox5
182 | //
183 | this.textBox5.Location = new System.Drawing.Point(135, 520);
184 | this.textBox5.Name = "textBox5";
185 | this.textBox5.Size = new System.Drawing.Size(465, 28);
186 | this.textBox5.TabIndex = 9;
187 | //
188 | // label6
189 | //
190 | this.label6.AutoSize = true;
191 | this.label6.Location = new System.Drawing.Point(58, 292);
192 | this.label6.Name = "label6";
193 | this.label6.Size = new System.Drawing.Size(44, 18);
194 | this.label6.TabIndex = 12;
195 | this.label6.Text = "SHA1";
196 | //
197 | // textBox6
198 | //
199 | this.textBox6.Location = new System.Drawing.Point(135, 283);
200 | this.textBox6.Name = "textBox6";
201 | this.textBox6.Size = new System.Drawing.Size(465, 28);
202 | this.textBox6.TabIndex = 11;
203 | //
204 | // label7
205 | //
206 | this.label7.AutoSize = true;
207 | this.label7.Location = new System.Drawing.Point(58, 352);
208 | this.label7.Name = "label7";
209 | this.label7.Size = new System.Drawing.Size(62, 18);
210 | this.label7.TabIndex = 14;
211 | this.label7.Text = "SHA256";
212 | //
213 | // textBox7
214 | //
215 | this.textBox7.Location = new System.Drawing.Point(135, 343);
216 | this.textBox7.Name = "textBox7";
217 | this.textBox7.Size = new System.Drawing.Size(465, 28);
218 | this.textBox7.TabIndex = 13;
219 | //
220 | // button2
221 | //
222 | this.button2.Location = new System.Drawing.Point(97, 200);
223 | this.button2.Name = "button2";
224 | this.button2.Size = new System.Drawing.Size(145, 84);
225 | this.button2.TabIndex = 21;
226 | this.button2.Text = "解密 解码";
227 | this.button2.UseVisualStyleBackColor = true;
228 | this.button2.Click += new System.EventHandler(this.button2_Click);
229 | //
230 | // button3
231 | //
232 | this.button3.Location = new System.Drawing.Point(97, 350);
233 | this.button3.Name = "button3";
234 | this.button3.Size = new System.Drawing.Size(145, 84);
235 | this.button3.TabIndex = 22;
236 | this.button3.Text = "密钥 对称";
237 | this.button3.UseVisualStyleBackColor = true;
238 | this.button3.Click += new System.EventHandler(this.button3_Click);
239 | //
240 | // panel1
241 | //
242 | this.panel1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel1.BackgroundImage")));
243 | this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
244 | this.panel1.Controls.Add(this.label8);
245 | this.panel1.Controls.Add(this.textBox8);
246 | this.panel1.Controls.Add(this.button5);
247 | this.panel1.Controls.Add(this.textBox1);
248 | this.panel1.Controls.Add(this.label1);
249 | this.panel1.Controls.Add(this.textBox2);
250 | this.panel1.Controls.Add(this.textBox6);
251 | this.panel1.Controls.Add(this.label2);
252 | this.panel1.Controls.Add(this.label6);
253 | this.panel1.Controls.Add(this.textBox3);
254 | this.panel1.Controls.Add(this.textBox7);
255 | this.panel1.Controls.Add(this.label7);
256 | this.panel1.Controls.Add(this.label3);
257 | this.panel1.Controls.Add(this.textBox4);
258 | this.panel1.Controls.Add(this.label4);
259 | this.panel1.Controls.Add(this.textBox5);
260 | this.panel1.Controls.Add(this.label5);
261 | this.panel1.Location = new System.Drawing.Point(318, 23);
262 | this.panel1.Name = "panel1";
263 | this.panel1.Size = new System.Drawing.Size(867, 689);
264 | this.panel1.TabIndex = 24;
265 | //
266 | // label8
267 | //
268 | this.label8.AutoSize = true;
269 | this.label8.Location = new System.Drawing.Point(58, 99);
270 | this.label8.Name = "label8";
271 | this.label8.Size = new System.Drawing.Size(44, 18);
272 | this.label8.TabIndex = 26;
273 | this.label8.Text = "明文";
274 | //
275 | // textBox8
276 | //
277 | this.textBox8.Location = new System.Drawing.Point(135, 89);
278 | this.textBox8.Name = "textBox8";
279 | this.textBox8.Size = new System.Drawing.Size(465, 28);
280 | this.textBox8.TabIndex = 25;
281 | //
282 | // button5
283 | //
284 | this.button5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
285 | this.button5.ForeColor = System.Drawing.SystemColors.ControlText;
286 | this.button5.Location = new System.Drawing.Point(660, 89);
287 | this.button5.Name = "button5";
288 | this.button5.Size = new System.Drawing.Size(128, 107);
289 | this.button5.TabIndex = 24;
290 | this.button5.Text = "Encode";
291 | this.button5.UseVisualStyleBackColor = true;
292 | this.button5.Click += new System.EventHandler(this.button5_Click);
293 | //
294 | // panel2
295 | //
296 | this.panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel2.BackgroundImage")));
297 | this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
298 | this.panel2.Controls.Add(this.textBox16);
299 | this.panel2.Controls.Add(this.button7);
300 | this.panel2.Controls.Add(this.label10);
301 | this.panel2.Controls.Add(this.comboBox1);
302 | this.panel2.Controls.Add(this.label9);
303 | this.panel2.Controls.Add(this.textBox9);
304 | this.panel2.Controls.Add(this.textBox12);
305 | this.panel2.Controls.Add(this.label12);
306 | this.panel2.Location = new System.Drawing.Point(318, 23);
307 | this.panel2.Name = "panel2";
308 | this.panel2.Size = new System.Drawing.Size(867, 689);
309 | this.panel2.TabIndex = 28;
310 | //
311 | // textBox16
312 | //
313 | this.textBox16.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
314 | this.textBox16.Location = new System.Drawing.Point(131, 365);
315 | this.textBox16.Name = "textBox16";
316 | this.textBox16.Size = new System.Drawing.Size(243, 28);
317 | this.textBox16.TabIndex = 30;
318 | this.textBox16.Text = "算法若未指定将尝试智能解码";
319 | //
320 | // button7
321 | //
322 | this.button7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
323 | this.button7.ForeColor = System.Drawing.SystemColors.ControlText;
324 | this.button7.Location = new System.Drawing.Point(479, 294);
325 | this.button7.Name = "button7";
326 | this.button7.Size = new System.Drawing.Size(202, 74);
327 | this.button7.TabIndex = 29;
328 | this.button7.Text = "Decode";
329 | this.button7.UseVisualStyleBackColor = true;
330 | this.button7.Click += new System.EventHandler(this.button7_Click);
331 | //
332 | // label10
333 | //
334 | this.label10.AutoSize = true;
335 | this.label10.Location = new System.Drawing.Point(139, 330);
336 | this.label10.Name = "label10";
337 | this.label10.Size = new System.Drawing.Size(44, 18);
338 | this.label10.TabIndex = 28;
339 | this.label10.Text = "算法";
340 | //
341 | // comboBox1
342 | //
343 | this.comboBox1.FormattingEnabled = true;
344 | this.comboBox1.Items.AddRange(new object[] {
345 | "BASE64",
346 | "URL",
347 | "HEX"});
348 | this.comboBox1.Location = new System.Drawing.Point(216, 322);
349 | this.comboBox1.Name = "comboBox1";
350 | this.comboBox1.Size = new System.Drawing.Size(149, 26);
351 | this.comboBox1.TabIndex = 27;
352 | //
353 | // label9
354 | //
355 | this.label9.AutoSize = true;
356 | this.label9.Location = new System.Drawing.Point(139, 174);
357 | this.label9.Name = "label9";
358 | this.label9.Size = new System.Drawing.Size(44, 18);
359 | this.label9.TabIndex = 26;
360 | this.label9.Text = "密文";
361 | //
362 | // textBox9
363 | //
364 | this.textBox9.Location = new System.Drawing.Point(216, 118);
365 | this.textBox9.Multiline = true;
366 | this.textBox9.Name = "textBox9";
367 | this.textBox9.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
368 | this.textBox9.Size = new System.Drawing.Size(465, 122);
369 | this.textBox9.TabIndex = 25;
370 | //
371 | // textBox12
372 | //
373 | this.textBox12.Location = new System.Drawing.Point(216, 415);
374 | this.textBox12.Multiline = true;
375 | this.textBox12.Name = "textBox12";
376 | this.textBox12.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
377 | this.textBox12.Size = new System.Drawing.Size(465, 122);
378 | this.textBox12.TabIndex = 5;
379 | //
380 | // label12
381 | //
382 | this.label12.AutoSize = true;
383 | this.label12.Location = new System.Drawing.Point(139, 471);
384 | this.label12.Name = "label12";
385 | this.label12.Size = new System.Drawing.Size(44, 18);
386 | this.label12.TabIndex = 6;
387 | this.label12.Text = "明文";
388 | //
389 | // panel3
390 | //
391 | this.panel3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel3.BackgroundImage")));
392 | this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
393 | this.panel3.Controls.Add(this.button8);
394 | this.panel3.Controls.Add(this.label15);
395 | this.panel3.Controls.Add(this.textBox13);
396 | this.panel3.Controls.Add(this.button6);
397 | this.panel3.Controls.Add(this.label11);
398 | this.panel3.Controls.Add(this.comboBox2);
399 | this.panel3.Controls.Add(this.label13);
400 | this.panel3.Controls.Add(this.textBox10);
401 | this.panel3.Controls.Add(this.textBox11);
402 | this.panel3.Controls.Add(this.label14);
403 | this.panel3.Location = new System.Drawing.Point(318, 23);
404 | this.panel3.Name = "panel3";
405 | this.panel3.Size = new System.Drawing.Size(867, 689);
406 | this.panel3.TabIndex = 29;
407 | //
408 | // button8
409 | //
410 | this.button8.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
411 | this.button8.ForeColor = System.Drawing.SystemColors.ControlText;
412 | this.button8.Location = new System.Drawing.Point(426, 319);
413 | this.button8.Name = "button8";
414 | this.button8.Size = new System.Drawing.Size(122, 74);
415 | this.button8.TabIndex = 32;
416 | this.button8.Text = "Encode";
417 | this.button8.UseVisualStyleBackColor = true;
418 | this.button8.Click += new System.EventHandler(this.button8_Click);
419 | //
420 | // label15
421 | //
422 | this.label15.AutoSize = true;
423 | this.label15.Location = new System.Drawing.Point(163, 238);
424 | this.label15.Name = "label15";
425 | this.label15.Size = new System.Drawing.Size(35, 18);
426 | this.label15.TabIndex = 31;
427 | this.label15.Text = "KEY";
428 | //
429 | // textBox13
430 | //
431 | this.textBox13.Location = new System.Drawing.Point(231, 238);
432 | this.textBox13.Multiline = true;
433 | this.textBox13.Name = "textBox13";
434 | this.textBox13.Size = new System.Drawing.Size(465, 37);
435 | this.textBox13.TabIndex = 30;
436 | //
437 | // button6
438 | //
439 | this.button6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
440 | this.button6.ForeColor = System.Drawing.SystemColors.ControlText;
441 | this.button6.Location = new System.Drawing.Point(574, 319);
442 | this.button6.Name = "button6";
443 | this.button6.Size = new System.Drawing.Size(122, 74);
444 | this.button6.TabIndex = 29;
445 | this.button6.Text = "Decode";
446 | this.button6.UseVisualStyleBackColor = true;
447 | this.button6.Click += new System.EventHandler(this.button6_Click);
448 | //
449 | // label11
450 | //
451 | this.label11.AutoSize = true;
452 | this.label11.Location = new System.Drawing.Point(154, 355);
453 | this.label11.Name = "label11";
454 | this.label11.Size = new System.Drawing.Size(44, 18);
455 | this.label11.TabIndex = 28;
456 | this.label11.Text = "算法";
457 | //
458 | // comboBox2
459 | //
460 | this.comboBox2.FormattingEnabled = true;
461 | this.comboBox2.Items.AddRange(new object[] {
462 | "RC4",
463 | "AES",
464 | "DES"});
465 | this.comboBox2.Location = new System.Drawing.Point(231, 347);
466 | this.comboBox2.Name = "comboBox2";
467 | this.comboBox2.Size = new System.Drawing.Size(149, 26);
468 | this.comboBox2.TabIndex = 27;
469 | //
470 | // label13
471 | //
472 | this.label13.AutoSize = true;
473 | this.label13.Location = new System.Drawing.Point(163, 115);
474 | this.label13.Name = "label13";
475 | this.label13.Size = new System.Drawing.Size(44, 18);
476 | this.label13.TabIndex = 26;
477 | this.label13.Text = "明文";
478 | //
479 | // textBox10
480 | //
481 | this.textBox10.Location = new System.Drawing.Point(231, 72);
482 | this.textBox10.Multiline = true;
483 | this.textBox10.Name = "textBox10";
484 | this.textBox10.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
485 | this.textBox10.Size = new System.Drawing.Size(465, 99);
486 | this.textBox10.TabIndex = 25;
487 | //
488 | // textBox11
489 | //
490 | this.textBox11.Location = new System.Drawing.Point(231, 452);
491 | this.textBox11.Multiline = true;
492 | this.textBox11.Name = "textBox11";
493 | this.textBox11.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
494 | this.textBox11.Size = new System.Drawing.Size(465, 99);
495 | this.textBox11.TabIndex = 5;
496 | //
497 | // label14
498 | //
499 | this.label14.AutoSize = true;
500 | this.label14.Location = new System.Drawing.Point(154, 496);
501 | this.label14.Name = "label14";
502 | this.label14.Size = new System.Drawing.Size(44, 18);
503 | this.label14.TabIndex = 6;
504 | this.label14.Text = "密文";
505 | //
506 | // button4
507 | //
508 | this.button4.Location = new System.Drawing.Point(97, 500);
509 | this.button4.Name = "button4";
510 | this.button4.Size = new System.Drawing.Size(145, 84);
511 | this.button4.TabIndex = 30;
512 | this.button4.Text = "密钥 非对称";
513 | this.button4.UseVisualStyleBackColor = true;
514 | this.button4.Click += new System.EventHandler(this.button4_Click);
515 | //
516 | // panel4
517 | //
518 | this.panel4.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel4.BackgroundImage")));
519 | this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
520 | this.panel4.Controls.Add(this.button11);
521 | this.panel4.Controls.Add(this.label22);
522 | this.panel4.Controls.Add(this.textBox19);
523 | this.panel4.Controls.Add(this.button10);
524 | this.panel4.Controls.Add(this.label18);
525 | this.panel4.Controls.Add(this.label21);
526 | this.panel4.Controls.Add(this.textBox15);
527 | this.panel4.Controls.Add(this.textBox18);
528 | this.panel4.Controls.Add(this.label20);
529 | this.panel4.Controls.Add(this.label19);
530 | this.panel4.Controls.Add(this.textBox17);
531 | this.panel4.Controls.Add(this.button9);
532 | this.panel4.Controls.Add(this.label16);
533 | this.panel4.Controls.Add(this.comboBox3);
534 | this.panel4.Controls.Add(this.textBox14);
535 | this.panel4.Location = new System.Drawing.Point(318, 23);
536 | this.panel4.Name = "panel4";
537 | this.panel4.Size = new System.Drawing.Size(867, 689);
538 | this.panel4.TabIndex = 31;
539 | //
540 | // button11
541 | //
542 | this.button11.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
543 | this.button11.ForeColor = System.Drawing.SystemColors.ControlText;
544 | this.button11.Location = new System.Drawing.Point(458, 14);
545 | this.button11.Name = "button11";
546 | this.button11.Size = new System.Drawing.Size(184, 69);
547 | this.button11.TabIndex = 41;
548 | this.button11.Text = "GetKeys";
549 | this.button11.UseVisualStyleBackColor = true;
550 | this.button11.Click += new System.EventHandler(this.button11_Click);
551 | //
552 | // label22
553 | //
554 | this.label22.AutoSize = true;
555 | this.label22.Location = new System.Drawing.Point(423, 510);
556 | this.label22.Name = "label22";
557 | this.label22.Size = new System.Drawing.Size(44, 18);
558 | this.label22.TabIndex = 40;
559 | this.label22.Text = "结果";
560 | //
561 | // textBox19
562 | //
563 | this.textBox19.Location = new System.Drawing.Point(216, 536);
564 | this.textBox19.Multiline = true;
565 | this.textBox19.Name = "textBox19";
566 | this.textBox19.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
567 | this.textBox19.Size = new System.Drawing.Size(444, 122);
568 | this.textBox19.TabIndex = 39;
569 | //
570 | // button10
571 | //
572 | this.button10.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
573 | this.button10.ForeColor = System.Drawing.SystemColors.ControlText;
574 | this.button10.Location = new System.Drawing.Point(219, 424);
575 | this.button10.Name = "button10";
576 | this.button10.Size = new System.Drawing.Size(202, 74);
577 | this.button10.TabIndex = 38;
578 | this.button10.Text = "Encode";
579 | this.button10.UseVisualStyleBackColor = true;
580 | this.button10.Click += new System.EventHandler(this.button10_Click);
581 | //
582 | // label18
583 | //
584 | this.label18.AutoSize = true;
585 | this.label18.Location = new System.Drawing.Point(580, 262);
586 | this.label18.Name = "label18";
587 | this.label18.Size = new System.Drawing.Size(62, 18);
588 | this.label18.TabIndex = 37;
589 | this.label18.Text = "待解密";
590 | //
591 | // label21
592 | //
593 | this.label21.AutoSize = true;
594 | this.label21.Location = new System.Drawing.Point(192, 262);
595 | this.label21.Name = "label21";
596 | this.label21.Size = new System.Drawing.Size(62, 18);
597 | this.label21.TabIndex = 36;
598 | this.label21.Text = "待加密";
599 | //
600 | // textBox15
601 | //
602 | this.textBox15.Location = new System.Drawing.Point(74, 287);
603 | this.textBox15.Multiline = true;
604 | this.textBox15.Name = "textBox15";
605 | this.textBox15.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
606 | this.textBox15.Size = new System.Drawing.Size(347, 122);
607 | this.textBox15.TabIndex = 35;
608 | //
609 | // textBox18
610 | //
611 | this.textBox18.Location = new System.Drawing.Point(458, 287);
612 | this.textBox18.Multiline = true;
613 | this.textBox18.Name = "textBox18";
614 | this.textBox18.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
615 | this.textBox18.Size = new System.Drawing.Size(360, 122);
616 | this.textBox18.TabIndex = 34;
617 | //
618 | // label20
619 | //
620 | this.label20.AutoSize = true;
621 | this.label20.Location = new System.Drawing.Point(580, 97);
622 | this.label20.Name = "label20";
623 | this.label20.Size = new System.Drawing.Size(44, 18);
624 | this.label20.TabIndex = 33;
625 | this.label20.Text = "私钥";
626 | //
627 | // label19
628 | //
629 | this.label19.AutoSize = true;
630 | this.label19.Location = new System.Drawing.Point(192, 97);
631 | this.label19.Name = "label19";
632 | this.label19.Size = new System.Drawing.Size(44, 18);
633 | this.label19.TabIndex = 32;
634 | this.label19.Text = "公钥";
635 | //
636 | // textBox17
637 | //
638 | this.textBox17.Location = new System.Drawing.Point(74, 118);
639 | this.textBox17.Multiline = true;
640 | this.textBox17.Name = "textBox17";
641 | this.textBox17.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
642 | this.textBox17.Size = new System.Drawing.Size(347, 122);
643 | this.textBox17.TabIndex = 31;
644 | //
645 | // button9
646 | //
647 | this.button9.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
648 | this.button9.ForeColor = System.Drawing.SystemColors.ControlText;
649 | this.button9.Location = new System.Drawing.Point(458, 424);
650 | this.button9.Name = "button9";
651 | this.button9.Size = new System.Drawing.Size(202, 74);
652 | this.button9.TabIndex = 29;
653 | this.button9.Text = "Decode";
654 | this.button9.UseVisualStyleBackColor = true;
655 | this.button9.Click += new System.EventHandler(this.button9_Click);
656 | //
657 | // label16
658 | //
659 | this.label16.AutoSize = true;
660 | this.label16.Location = new System.Drawing.Point(192, 34);
661 | this.label16.Name = "label16";
662 | this.label16.Size = new System.Drawing.Size(44, 18);
663 | this.label16.TabIndex = 28;
664 | this.label16.Text = "算法";
665 | //
666 | // comboBox3
667 | //
668 | this.comboBox3.FormattingEnabled = true;
669 | this.comboBox3.Items.AddRange(new object[] {
670 | "RSA"});
671 | this.comboBox3.Location = new System.Drawing.Point(245, 31);
672 | this.comboBox3.Name = "comboBox3";
673 | this.comboBox3.Size = new System.Drawing.Size(176, 26);
674 | this.comboBox3.TabIndex = 27;
675 | //
676 | // textBox14
677 | //
678 | this.textBox14.Location = new System.Drawing.Point(458, 118);
679 | this.textBox14.Multiline = true;
680 | this.textBox14.Name = "textBox14";
681 | this.textBox14.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
682 | this.textBox14.Size = new System.Drawing.Size(360, 122);
683 | this.textBox14.TabIndex = 25;
684 | //
685 | // form
686 | //
687 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
688 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
689 | this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
690 | this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
691 | this.ClientSize = new System.Drawing.Size(1336, 733);
692 | this.Controls.Add(this.panel4);
693 | this.Controls.Add(this.button4);
694 | this.Controls.Add(this.panel3);
695 | this.Controls.Add(this.panel2);
696 | this.Controls.Add(this.panel1);
697 | this.Controls.Add(this.button3);
698 | this.Controls.Add(this.button2);
699 | this.Controls.Add(this.button1);
700 | this.DoubleBuffered = true;
701 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
702 | this.Name = "form";
703 | this.Text = "RCoder V1.0 @ RabbitMask ";
704 | this.panel1.ResumeLayout(false);
705 | this.panel1.PerformLayout();
706 | this.panel2.ResumeLayout(false);
707 | this.panel2.PerformLayout();
708 | this.panel3.ResumeLayout(false);
709 | this.panel3.PerformLayout();
710 | this.panel4.ResumeLayout(false);
711 | this.panel4.PerformLayout();
712 | this.ResumeLayout(false);
713 |
714 | }
715 |
716 | #endregion
717 |
718 | private System.Windows.Forms.TextBox textBox1;
719 | private System.Windows.Forms.Button button1;
720 | private System.Windows.Forms.Label label1;
721 | private System.Windows.Forms.Label label2;
722 | private System.Windows.Forms.TextBox textBox2;
723 | private System.Windows.Forms.Label label3;
724 | private System.Windows.Forms.TextBox textBox3;
725 | private System.Windows.Forms.Label label4;
726 | private System.Windows.Forms.TextBox textBox4;
727 | private System.Windows.Forms.Label label5;
728 | private System.Windows.Forms.TextBox textBox5;
729 | private System.Windows.Forms.TextBox textBox6;
730 | private System.Windows.Forms.Label label7;
731 | private System.Windows.Forms.TextBox textBox7;
732 | private System.Windows.Forms.Button button2;
733 | private System.Windows.Forms.Button button3;
734 | private System.Windows.Forms.Panel panel1;
735 | private System.Windows.Forms.Label label6;
736 | private System.Windows.Forms.Label label8;
737 | private System.Windows.Forms.TextBox textBox8;
738 | private System.Windows.Forms.Button button5;
739 | private System.Windows.Forms.Panel panel2;
740 | private System.Windows.Forms.ComboBox comboBox1;
741 | private System.Windows.Forms.Label label9;
742 | private System.Windows.Forms.TextBox textBox9;
743 | private System.Windows.Forms.TextBox textBox12;
744 | private System.Windows.Forms.Label label12;
745 | private System.Windows.Forms.Button button7;
746 | private System.Windows.Forms.Label label10;
747 | private System.Windows.Forms.Panel panel3;
748 | private System.Windows.Forms.Button button8;
749 | private System.Windows.Forms.Label label15;
750 | private System.Windows.Forms.TextBox textBox13;
751 | private System.Windows.Forms.Button button6;
752 | private System.Windows.Forms.Label label11;
753 | private System.Windows.Forms.ComboBox comboBox2;
754 | private System.Windows.Forms.Label label13;
755 | private System.Windows.Forms.TextBox textBox10;
756 | private System.Windows.Forms.TextBox textBox11;
757 | private System.Windows.Forms.Label label14;
758 | private System.Windows.Forms.Button button4;
759 | private System.Windows.Forms.Panel panel4;
760 | private System.Windows.Forms.Button button9;
761 | private System.Windows.Forms.Label label16;
762 | private System.Windows.Forms.ComboBox comboBox3;
763 | private System.Windows.Forms.TextBox textBox14;
764 | private System.Windows.Forms.Label label22;
765 | private System.Windows.Forms.TextBox textBox19;
766 | private System.Windows.Forms.Button button10;
767 | private System.Windows.Forms.Label label18;
768 | private System.Windows.Forms.Label label21;
769 | private System.Windows.Forms.TextBox textBox15;
770 | private System.Windows.Forms.TextBox textBox18;
771 | private System.Windows.Forms.Label label20;
772 | private System.Windows.Forms.Label label19;
773 | private System.Windows.Forms.TextBox textBox17;
774 | private System.Windows.Forms.Button button11;
775 | private System.Windows.Forms.TextBox textBox16;
776 | }
777 | }
778 |
779 |
--------------------------------------------------------------------------------
/form.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 |
10 | namespace RCoder
11 | {
12 | public partial class form : Form
13 | {
14 | public form()
15 | {
16 | InitializeComponent();
17 | PanelIsDisplay(0);
18 | }
19 |
20 |
21 | Encoder encoder = new Encoder();
22 | Decoder decoder = new Decoder();
23 | RC4 rc4 = new RC4();
24 | RSA rsa = new RSA();
25 | AES aes = new AES();
26 | DES des = new DES();
27 |
28 |
29 | private void PanelIsDisplay(int p)
30 | {
31 | panel1.Visible = false;
32 | panel2.Visible = false;
33 | panel3.Visible = false;
34 | panel4.Visible = false;
35 |
36 | switch (p)
37 | {
38 | case 1:
39 | {
40 | panel1.Visible = true;
41 | }
42 | break;
43 | case 2:
44 | {
45 | panel2.Visible = true;
46 | }
47 | break;
48 | case 3:
49 | {
50 | panel3.Visible = true;
51 | }
52 | break;
53 | case 4:
54 | {
55 | panel4.Visible = true;
56 | }
57 | break;
58 | default:
59 | {
60 | panel1.Visible = false;
61 | panel2.Visible = false;
62 | panel3.Visible = false;
63 | panel4.Visible = false;
64 | }
65 | break;
66 | }
67 | }
68 |
69 |
70 | private void button1_Click(object sender, EventArgs e)
71 | {
72 | PanelIsDisplay(1);
73 | }
74 | private void button2_Click(object sender, EventArgs e)
75 | {
76 | PanelIsDisplay(2);
77 | }
78 |
79 | private void button3_Click(object sender, EventArgs e)
80 | {
81 | PanelIsDisplay(3);
82 | }
83 | private void button4_Click(object sender, EventArgs e)
84 | {
85 | PanelIsDisplay(4);
86 | }
87 |
88 | private void button5_Click(object sender, EventArgs e)
89 | {
90 | textBox1.Text = encoder.Rmd5_16(textBox8.Text);
91 | textBox2.Text = encoder.Rmd5_32(textBox8.Text);
92 | textBox3.Text = encoder.Rurl(textBox8.Text);
93 | textBox4.Text = encoder.Rbase64(textBox8.Text);
94 | textBox5.Text = encoder.Rhex(textBox8.Text);
95 | textBox6.Text = encoder.Rsha1(textBox8.Text);
96 | textBox7.Text = encoder.Rsha256(textBox8.Text);
97 | }
98 |
99 | private void button7_Click(object sender, EventArgs e)
100 | {
101 | if (comboBox1.Text == "BASE64")
102 | {
103 | textBox12.Text = decoder.Rbase64(textBox9.Text);
104 | }
105 | else if (comboBox1.Text == "URL")
106 | {
107 | textBox12.Text = decoder.Rurl(textBox9.Text);
108 | }
109 | else if (comboBox1.Text == "HEX")
110 | {
111 | textBox12.Text = decoder.Rhex(textBox9.Text);
112 | }
113 | else
114 | {
115 | try { textBox12.Text = decoder.Rbase64(textBox9.Text);} catch { }
116 | try { textBox12.Text = decoder.Rurl(textBox9.Text); } catch { }
117 | try { textBox12.Text = decoder.Rhex(textBox9.Text); } catch { }
118 | }
119 |
120 | }
121 |
122 | private void button8_Click(object sender, EventArgs e)
123 | {
124 | if (comboBox2.Text == "RC4")
125 | {
126 | textBox11.Text = rc4.Encrypt(textBox13.Text,textBox10.Text);
127 | }
128 | else if (comboBox2.Text == "AES")
129 | {
130 | try
131 | {
132 | textBox11.Text = aes.Encrypt(textBox10.Text, textBox13.Text);
133 | }
134 | catch (System.Security.Cryptography.CryptographicException)
135 | {
136 | MessageBox.Show("AES密钥长度要求为16的倍数", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
137 | }
138 |
139 | }
140 | else if (comboBox2.Text == "DES")
141 | {
142 | try
143 | {
144 | textBox11.Text = des.Encrypt(textBox10.Text, textBox13.Text);
145 | }
146 | catch (ArgumentException)
147 | {
148 | MessageBox.Show("DES密钥长度要求为8: \r\n标准的DES密钥长度为64bit,密钥每个字符占7bit,奇偶校验占1bit", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
149 | }
150 | }
151 | else
152 | {
153 | MessageBox.Show("算法类型未选择,请指定算法后再进行后续操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
154 | }
155 | }
156 |
157 | private void button6_Click(object sender, EventArgs e)
158 | {
159 | if (comboBox2.Text == "RC4")
160 | {
161 | textBox10.Text = rc4.Decrypt(textBox13.Text, textBox11.Text);
162 | }
163 | else
164 | {
165 | MessageBox.Show("算法类型未选择,请指定算法后再进行后续操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
166 | }
167 | }
168 |
169 | private void button11_Click(object sender, EventArgs e)
170 | {
171 | if (comboBox3.Text == "RSA")
172 | {
173 | string[] key = rsa.GetKeys();
174 | textBox14.Text = key[0];
175 | textBox17.Text = key[1];
176 | }
177 | else
178 | {
179 | MessageBox.Show("算法类型未选择,请指定算法后再进行后续操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
180 | }
181 | }
182 |
183 | private void button10_Click(object sender, EventArgs e)
184 | {
185 | if (comboBox3.Text == "RSA")
186 | {
187 | textBox19.Text = rsa.Encrypt(textBox15.Text, textBox17.Text);
188 | }
189 | else
190 | {
191 | MessageBox.Show("算法类型未选择,请指定算法后再进行后续操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
192 | }
193 |
194 | }
195 |
196 | private void button9_Click(object sender, EventArgs e)
197 | {
198 | if (comboBox3.Text == "RSA")
199 | {
200 | textBox19.Text = rsa.Decrypt(textBox18.Text, textBox14.Text);
201 | }
202 | else
203 | {
204 | MessageBox.Show("算法类型未选择,请指定算法后再进行后续操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
205 | }
206 |
207 |
208 | }
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/img/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/img/1.jpg
--------------------------------------------------------------------------------
/img/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/img/2.jpg
--------------------------------------------------------------------------------
/img/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/img/3.jpg
--------------------------------------------------------------------------------
/img/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/img/4.jpg
--------------------------------------------------------------------------------
/img/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/img/5.jpg
--------------------------------------------------------------------------------
/rcoder.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rabbitmask/RCoder/64dbd122dee46f7b75466e93c4afa799733d4079/rcoder.ico
--------------------------------------------------------------------------------