/// <summary> /// 加密索引表建立 /// </summary> /// <param name="filePath"></param> /// <param name="key"></param> /// <returns></returns> public static Dictionary <int, List <saveInfo> > basicEncry(string filePath, byte[] key) { Dictionary <int, List <saveInfo> > dic = new Dictionary <int, List <saveInfo> >(); if (File.Exists(filePath)) { using (FileStream fs = File.Open(filePath, FileMode.Open)) { using (StreamReader sr = new StreamReader(fs)) { string s = null; while ((s = sr.ReadLine()) != null) { if (s != "" && s != " ") { string[] args = s.Split(' '); List <byte[]> list = new List <byte[]>(); for (int i = 1; i < 6; i++) { list.Add(tool.WordToHash()); } List <saveInfo> infoList = new List <saveInfo>(); foreach (var item in list) { saveInfo info = new saveInfo(item, tool.HmacHashByte(key, item)); infoList.Add(info); } dic.Add(Convert.ToInt32(args[0]), infoList); } } } } } return(dic); }
/// <summary> /// 累加值索引 /// </summary> /// <param name="filePath"></param> /// <param name="key"></param> /// <returns></returns> public static Dictionary <int, saveInfo> Acculumator(string filePath, byte[] key) { string s = null; Dictionary <int, saveInfo> dic = new Dictionary <int, saveInfo>(); if (File.Exists(filePath)) { using (FileStream stream = File.Open(filePath, FileMode.Open)) { using (StreamReader sr = new StreamReader(stream)) { while ((s = sr.ReadLine()) != null) { if (s != "" && s != " ") { string[] args = s.Split(' '); byte[] IDBytes = Encoding.UTF8.GetBytes(args[0]); byte[] hashBytes = tool.HmacHashByte(IDBytes, key); saveInfo info = new saveInfo(IDBytes, hashBytes); dic.Add(int.Parse(args[0]), info); } } } } } return(dic); }