首先引入 using System.Windows.Media;
1 var strSecert = cs.strSecerts; 2 var dict = new Dictionary<int, string>(); 3 ICollection<FontFamily> fontFamilies = Fonts.GetFontFamilies(fontFamiliesPath); 4 var families = Fonts.GetFontFamilies(familiesPath); 5 6 foreach (FontFamily family in families) 7 { 8 var typefaces = family.GetTypefaces(); 9 foreach (Typeface typeface in typefaces) 10 { 11 GlyphTypeface glyph; 12 typeface.TryGetGlyphTypeface(out glyph); 13 IDictionary<int, ushort> characterMap = glyph.CharacterToGlyphMap; 14 foreach (KeyValuePair<int, ushort> kvp in characterMap) 15 { 16 if (!dict.Any(t => t.Key == kvp.Key)) 17 { 18 dict.Add(kvp.Key, kvp.Value.ToString()); 19 } 20 } 21 } 22 } 23 var resultStr = ""; 24 for (int i = 0; i < strSecert.Length; i++) 25 { 26 var chars = Char.ConvertToUtf32(strSecert, i); 27 var item = dict.FirstOrDefault(t => t.Key == chars); 28 // resultStr = item.Value; 29 var ss = int.Parse(item.Value) - 1; 30 resultStr += ss.ToString(); 31 } 32 var ff = resultStr;
strSecert变量为乱码(加密)文字
resultStr变量为破解后文字
fontFamiliesPath/familiesPath 变量都为TTF字体文件路径