我有以下c#代码行:
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
我需要在web.config中存储十六进制值列表:
<add key="BytesVector" value="0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76" />
然后使用这样的值:
var vector = ConfigurationManager.AppSettings["BytesVector"].ToString();
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { someParsingHere(vector) });
任何线索?
string s = "0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76";
var list = s.Split(',');
byte[] bytes = new byte[list.Length];
for(int i=0; i<list.Count(); i++)
{
bytes[i] = Convert.ToByte(number.Trim(), 16);
}