bool CheckEncryptedMethod(MethodDef method, out EncryptInfo info) { info = null; if (method.Body == null) { return(false); } if (!CallsExecuteMethod(method)) { return(false); } var strings = DotNetUtils.GetCodeStrings(method); if (strings.Count != 1) { throw new ApplicationException("Could not find name of encrypted method"); } string feature = ""; string name = strings[0]; int index = name.IndexOf(':'); if (index >= 0) { feature = name.Substring(0, index); name = name.Substring(index + 1); } info = new EncryptInfo(name, feature, method); return(true); }
protected override void OnConstructor() { m_Rijndael = Rijndael.Create(); m_EncryptInfo = CreateEncryptInfo(); m_Rijndael.IV = m_EncryptInfo.Iv; m_Rijndael.Key = m_EncryptInfo.Key; }
public void DencryptTest() { IEncrypt encrypt = new EncryptRSA(); EncryptInfo pwd = new EncryptInfo("QNKz7wMTPJt0UVfOtat0e/az3DrBs00kybYWaC2dhPn+dGATC7xkyBPXitiZfJHxcefunio4aW1Oc3BlC3QIggo/XT2cRE3lRsClOOxyrrTHWmynYkF4pSKr/xIl64fdjm+taOAJHjdeg6iW5V4AMEpnYLNwLoIQCwzNU5+o5yM=", Encoding.UTF8); pwd.Key = @"<RSAKeyValue><Modulus>5m9m14XH3oqLJ8bNGw9e4rGpXpcktv9MSkHSVFVMjHbfv+SJ5v0ubqQxa5YjLN4vc49z7SVju8s0X4gZ6AzZTn06jzWOgyPRV54Q4I0DCYadWW4Ze3e+BOtwgVU1Og3qHKn8vygoj40J6U85Z/PTJu3hN1m75Zr195ju7g9v4Hk=</Modulus><Exponent>AQAB</Exponent><P>/hf2dnK7rNfl3lbqghWcpFdu778hUpIEBixCDL5WiBtpkZdpSw90aERmHJYaW2RGvGRi6zSftLh00KHsPcNUMw==</P><Q>6Cn/jOLrPapDTEp1Fkq+uz++1Do0eeX7HYqi9rY29CqShzCeI7LEYOoSwYuAJ3xA/DuCdQENPSoJ9KFbO4Wsow==</Q><DP>ga1rHIJro8e/yhxjrKYo/nqc5ICQGhrpMNlPkD9n3CjZVPOISkWF7FzUHEzDANeJfkZhcZa21z24aG3rKo5Qnw==</DP><DQ>MNGsCB8rYlMsRZ2ek2pyQwO7h/sZT8y5ilO9wu08Dwnot/7UMiOEQfDWstY3w5XQQHnvC9WFyCfP4h4QBissyw==</DQ><InverseQ>EG02S7SADhH1EVT9DD0Z62Y0uY7gIYvxX/uq+IzKSCwB8M2G7Qv9xgZQaQlLpCaeKbux3Y59hHM+KpamGL19Kg==</InverseQ><D>vmaYHEbPAgOJvaEXQl+t8DQKFT1fudEysTy31LTyXjGu6XiltXXHUuZaa2IPyHgBz0Nd7znwsW/S44iql0Fen1kzKioEL3svANui63O3o5xdDeExVM6zOf1wUUh/oldovPweChyoAdMtUzgvCbJk1sYDJf++Nr0FeNW1RB1XG30=</D></RSAKeyValue>"; var result = encrypt.Dencrypt(pwd); Assert.AreEqual("123456", result); }
//解密信息返回 void repEncryptInfo(System.Object msg) { Debug.Log("repEncryptInfo handle:" + (int)twp.protocol.fep2c.kMSGIDX_REP_ENCRYPT_INFO); EncryptInfo info = msg as EncryptInfo; //替换本地秘钥 yw.YwEncrypt.SetKey(info.key); Sender.sendLoginFirstAccountInfo(); }
/// <summary> /// 暗号化情報を生成して返す。 /// </summary> public static EncryptInfo CreateEncryptInfo() { var byteGenerator = new Rfc2898DeriveBytes(GetPassword(), GetSalt(), 1000); var random = new RNGCryptoServiceProvider(); var info = new EncryptInfo(); var iv = new byte[IV_LENGTH]; random.GetBytes(iv); info.Iv = iv; info.Key = byteGenerator.GetBytes(KEY_LENGTH); return(info); }
public void EncryptTest() { IEncrypt encrypt = new EncryptRSA(); EncryptInfo pwd = new EncryptInfo("123456", Encoding.UTF8); //pwd.Key = @"<RSAKeyValue><Modulus>5m9m14XH3oqLJ8bNGw9e4rGpXpcktv9MSkHSVFVMjHbfv+SJ5v0ubqQxa5YjLN4vc49z7SVju8s0X4gZ6AzZTn06jzWOgyPRV54Q4I0DCYadWW4Ze3e+BOtwgVU1Og3qHKn8vygoj40J6U85Z/PTJu3hN1m75Zr195ju7g9v4Hk=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"; //var result = encrypt.Encrypt(pwd); //var result1 = new EncryptSHA1().Encrypt(pwd); //pwd.Source = "us=张三&xin=113"; //var result2 = new EncryptEncode().Encrypt(pwd); //Assert.AreEqual("us%3d%e5%bc%a0%e4%b8%89%26xin%3d113", result2); //Assert.AreEqual("7c4a8d09ca3762af61e59520943dc26494f8941b", result1.ToLower()); pwd.Key = "12345678901234567890ab"; pwd.Iv = "1234567890abcd"; var temp = new EncryptAES().Encrypt(pwd); pwd.Source = temp; var temp2 = new EncryptAES().Dencrypt(pwd); }
private void btnDecrypt_Click(object sender, EventArgs e) { try { EncryptInfo encrypt = new EncryptInfo(this.txtSource.Text, Encoding.GetEncoding(this.cbxEncode.SelectedValue.ToString())); encrypt.Iv = this.txtIV.Text; encrypt.Key = this.txtKey.Text; IEncrypt obj = (IEncrypt)CreateInstance("EncryptBLL.Encrypt" + this.cbxType.SelectedValue); string checkeMsg = obj.Check(encrypt); if (string.Empty != checkeMsg) { MessageBox.Show(checkeMsg); return; } this.txtPassword.Text = obj.Dencrypt(encrypt); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
bool checkEncryptedMethod(MethodDefinition method, out EncryptInfo info) { info = null; if (method.Body == null) return false; if (!callsExecuteMethod(method)) return false; var strings = DotNetUtils.getCodeStrings(method); if (strings.Count != 1) throw new ApplicationException(string.Format("Could not find name of encrypted method")); string feature = ""; string name = strings[0]; int index = name.IndexOf(':'); if (index >= 0) { feature = name.Substring(0, index); name = name.Substring(index + 1); } info = new EncryptInfo(name, feature, method); return true; }