我坚持使用加密方法。我对加密或字节数组的了解不多,所以我很难解决这个问题。
这是我的代码:
public static class EncryptDecrypt {
private static byte[] key = { };
private static string sEncryptionKey = "B@|@j!";
private static byte[] IV = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab};
public static string Encrypt(string stringToEncrypt)
{
string returnstring = "";
try
{
key = System.Text.Encoding.UTF8.GetBytes(sEncryptionKey);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
CryptoStream cs = new CryptoStream(ms,
des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
returnstring = Convert.ToBase64String(ms.ToArray());
//URL Encryption Avoid Reserved Characters …Run Code Online (Sandbox Code Playgroud) 让我们考虑以下数据表:
Id Name PhoneNo
1 Sam 123654
2 Mike 213654
3 John 998745
Run Code Online (Sandbox Code Playgroud)
我需要来自此数据列表的Mike的Id并返回int值.我使用AllTestViews方法从数据库中检索所有这些数据作为项目列表.
int id= gateway.AllTestViews().//Something//(a => a.TestName=="Mike")
return id;
Run Code Online (Sandbox Code Playgroud)
有没有办法获得此ID或我必须使用SQL查询此问题?谢谢