public static string Encrypt(string key) { string timespan = TimeConvert.GetCurrentUTCTimeSpan(); string mixedKey = $"{timespan}&{key}&{_desKey}"; return(DESProvider.Encrypt(mixedKey, _desKey)); }
//生成推荐链接 private string generateRecommendUrl() { string id = getRecommendId(); if (id != null) { id = DESProvider.Encrypt(id, ConstantList.ENCRYPT_KEY); } return("http://" + Request.Url.Host + "/" + RouteData.Route.GetRouteData(this.HttpContext).Values["controller"] + "/decoderRecommendUrl?param=" + id + "&type=recommend"); }
public void DESTest() { ISymmetricCrypto codec = new DESProvider("test"); string org = "hello"; string res = codec.Encrypt(org); Assert.IsTrue(res != org); string org1 = codec.Decrypt(res); Assert.IsTrue(org == org1); codec.Dispose(); }
private void ProcessCipher(OperationType OpType) { try { if (OpType == OperationType.EncryptText) { byte[] EnBytesBuffer = DesProvider.Encrypt(Encoding.ASCII.GetBytes(textBox1.Text), "ESHKETIT"); Update_EncryptedText_LOGIN(Convert.ToBase64String(EnBytesBuffer)); } } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//添加用户到表 private void addUser(LoginModel model, DateTime now, Guid guid) { User newUser = new User(); newUser.UserId = guid; //特殊字符过滤 newUser.LoginName = FilterTools.FilterSpecial(model.Phone); newUser.Password = DESProvider.Encrypt(FilterTools.FilterSpecial(model.FirstPassword), ConstantList.PASSWORD_ENCRYPT); newUser.WeiXinId = GetUData.OpenId; newUser.TrueName = ""; newUser.CreateTime = now; newUser.UpdateTime = now; newUser.isDeleted = false; UserBiz userBiz = new UserBiz(); userBiz.Add(newUser); }
/// <summary> /// Does the actual saving. /// </summary> public override void Close() { // save the file to the filestream FileStream fs = new FileStream(Filename, FileMode.Create); if (Encryption == EncryptionType.AES) { fs.Write(AESProvider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.ASCII) { fs.Write(Utilities.StringToByte(ASCIIProvider.Encrypt(Utilities.ByteToString(Text.ToArray()))), 0, Text.Count); } if (Encryption == EncryptionType.DES) { fs.Write(DESProvider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.L1F3) { fs.Write(L1F3Provider.Encrypt(Utilities.ByteToString(Text.ToArray())), 0, Text.Count); } if (Encryption == EncryptionType.RC2) { fs.Write(RC2Provider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.Rijndael) { fs.Write(RijndaelProvider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.RSA) { fs.Write(RSAProvider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.TripleDES) { fs.Write(TripleDESProvider.Encrypt(Text.ToArray()), 0, Text.Count); } if (Encryption == EncryptionType.Xor) { fs.Write(Utilities.StringToByte(XorProvider.Encrypt(Utilities.ByteToString(Text.ToArray()))), 0, Text.Count); } fs.Close(); base.Close(); }
public static LuaValue Encrypt(LuaValue[] args) { string encType = (args[0] as LuaString).Text.ToLower(); string _in = args[1].ToString(); if (encType == "aes") { return(new LuaString(AESProvider.Encrypt(_in))); } else if (encType == "ascii") { // encrypt with first byte of key return(new LuaString(ASCIIProvider.Encrypt(_in))); } if (encType == "des") { return(new LuaString(DESProvider.Encrypt(_in))); } if (encType == "rc2") { return(new LuaString(RC2Provider.Encrypt(_in))); } if (encType == "rijndael") { return(new LuaString(RijndaelProvider.Encrypt(_in))); } if (encType == "rsa") { return(new LuaString(RSAProvider.Encrypt(_in))); } if (encType == "tripledes") { return(new LuaString(TripleDESProvider.Encrypt(_in))); } if (encType == "xor") { return(new LuaString(XorProvider.Encrypt(_in))); } throw new Exception("Unsuported encryption '" + encType + "'!"); }
protected void aebtn_Click(object sender, EventArgs e) { string data = TextBox1.Text; TextBox2.Text = DESProvider.Encrypt(data, "362514"); }