文本混淆-第二部分,共二部分
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了文本混淆-第二部分,共二部分相关的知识,希望对你有一定的参考价值。
using System; using System.Diagnostics; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Windows.Forms; namespace Kyrathasoft.Obfuscate { public static class serTextManip { private enum Operation{Serializing,Deserializing}; public static string DeserializeSerText(string filePath){ serText sert; try { sert = (serText)bFormatter.Deserialize(fStream); filePath = sert.TheText; if (sert.Shift) { filePath = shifted(filePath,Operation.Deserializing); } if (sert.Reverse) { filePath = stringReversed(filePath); } if ((sert.StartIndex > 0) || (sert.TheLength < sert.TheText.Length)) { filePath = filePath.Substring(sert.StartIndex, sert.TheLength); } } catch (Exception exception) { MessageBox.Show(exception.Message); } finally { if (fStream != null) { fStream.Close(); } } return filePath; } public static void SerializeSerText(string filePath, serText stObject) { serText st = stObject; if(st.Reverse){ st.TheText = stringReversed(st.TheText);} if (st.Shift) { st.TheText = shifted(st.TheText, Operation.Serializing); } try { bFormatter.Serialize(fs, st); } catch (Exception exception) { MessageBox.Show(exception.Message); } finally { if (fs != null) { fs.Close(); } } //end SerializePlainText, next line } private static string stringReversed(string inputString) { if (inputString == null) return null; // this was posted by petebob as well char[] array = inputString.ToCharArray(); Array.Reverse(array); string s = string.Empty; foreach (char c in array) { s += c; } return s; } private static string shifted(string inputString, Operation op) { string s = string.Empty; char[] array = inputString.ToCharArray(); int i; foreach (char c in array) { if(op == Operation.Serializing){ i = Convert.ToInt32((int)c) + 1; }else{ i = Convert.ToInt32((int)c)-1; } s += (char)i; } return s; } //end class next line } }
以上是关于文本混淆-第二部分,共二部分的主要内容,如果未能解决你的问题,请参考以下文章