public static string stegoZWCret(string fileName) { List <char> lista = WordDocument.returnChars(fileName); List <bool> binary = new List <bool>(); int end = 0; int bajt = 0; for (int i = 0; i < lista.Count; i++) { if (lista[i] == ' ') { if ((int)lista[i - 1] == 8203) { binary.Add(true); end = 0; } else { binary.Add(false); end++; } if ((int)lista[i + 1] == 8203) { binary.Add(true); end = 0; } else { binary.Add(false); end++; } } if (end > 7 && bajt == 7) { break; } bajt = (bajt == 7) ? 0 : bajt + 1; } string toRet = binaryToString(binary); return(toRet); }
public static string stegoHuffmanRet(string fileName, Dictionary <char, int> frequencies) { string toRet = ""; List <bool> binary = new List <bool>(); List <char> chars; chars = WordDocument.returnChars(fileName); HuffmanTree huffTree = new HuffmanTree(); huffTree.Frequencies = frequencies; huffTree.buildFromFrequences(); for (int i = 0; i < chars.Count; i++) { if (chars[i] == ' ') { string temp; if (chars[i + 1] == ' ') { binary.Add(true); i++; temp = huffTree.decodeChar(true); } else { binary.Add(false); temp = huffTree.decodeChar(false); } if (temp != string.Empty && temp != "\0") { toRet += temp; } if (temp == "\0") { break; } } } return(toRet); }
public static string stegoCharRet(string fileName, int[] stegoKey, string[] compressKey, List <string> table) { string toRet = ""; List <char> lista = WordDocument.returnChars(fileName); List <bool> binary = new List <bool>(); int end = 0; int bajt = 0; int i = 0; List <int> key = stegoKey.ToList(); while (i + 4 < lista.Count) { int group = 0; for (int j = 0; j < 4; j++) { int value = (int)lista[i + 1]; int n = key.IndexOf(value); if (n < 0) { break; } for (int k = group; k < n; k++) { binary.Add(false); group++; end++; bajt++; } if (group < 4) { binary.Add(true); group++; i++; end = 0; bajt++; } } while (group < 4) { binary.Add(false); group++; end++; bajt++; } i++; if (table != null) { if (binary.Count >= table.Count * 2) { break; } } else { if (end > 7 && bajt == 8) { break; } if (bajt == 8) { bajt = 0; } } } if (table != null) { binary = groupDecompress(binary, table, compressKey); } toRet = binaryToString(binary); return(toRet); }