基于C#的web开发
各位亲们,菜鸟求帮助,我们头儿给了我两个做好的web网页,他让我做主页里面包括用户登录,添加用户等东西,我现在不知道从哪里开始
看来你门都没入,怎么就开始上班了呢?准备好有书看书,没书就百度、谷歌狂搜吧,这个不难的,花十几个小时也就搞定了。
新建页面->放置控件->获取数据->判断逻辑->根据判断结果动作,就这么简单,呵呵!
using System; using using System.Text; namespace CC { public static class Security { #region 常量 const string Salt = "10242048"; const string Pwdv = "40968192"; #endregion public static string EncryptString(string input) { var data = Encoding.UTF8.GetBytes(input); var salt = Encoding.UTF8.GetBytes(Salt); var aes = new System.Security.Cryptography.AesManaged(); var rfc = new System.Security.Cryptography.Rfc2898DeriveBytes(Pwdv, salt); aes.BlockSize = aes.LegalBlockSizes[0].MaxSize; aes.KeySize = aes.LegalKeySizes[0].MaxSize; aes.Key = rfc.GetBytes(aes.KeySize / 8); aes.IV = rfc.GetBytes(aes.BlockSize / 8); System.Security.Cryptography.ICryptoTransform encryptTransform = aes.CreateEncryptor(); var encryptStream = new MemoryStream(); var encryptor = new System.Security.Cryptography.CryptoStream (encryptStream, encryptTransform, System.Security.Cryptography.CryptoStreamMode.Write); encryptor.Write(data, 0, data.Length); encryptor.Close(); var encryptedString = Convert.ToBase64String(encryptStream.ToArray()); return encryptedString; } public static string DecryptString(string input) { var encryptBytes = Convert.FromBase64String(input); var salt = Encoding.UTF8.GetBytes(Salt); var aes = new System.Security.Cryptography.AesManaged(); var rfc = new System.Security.Cryptography.Rfc2898DeriveBytes(Pwdv, salt); aes.BlockSize = aes.LegalBlockSizes[0].MaxSize; aes.KeySize = aes.LegalKeySizes[0].MaxSize; aes.Key = rfc.GetBytes(aes.KeySize / 8); aes.IV = rfc.GetBytes(aes.BlockSize / 8); System.Security.Cryptography.ICryptoTransform decryptTransform = aes.CreateDecryptor(); var decryptStream = new MemoryStream(); var decryptor = new System.Security.Cryptography.CryptoStream( decryptStream, decryptTransform, System.Security.Cryptography.CryptoStreamMode.Write); decryptor.Write(encryptBytes, 0, encryptBytes.Length); decryptor.Close(); var decryptBytes = decryptStream.ToArray(); var decryptedString = Encoding.UTF8.GetString(decryptBytes, 0, decryptBytes.Length); return decryptedString; } } }