public void OnGenCipherButtonClick() { string path = FileBrowser.SaveFile("Save Result as .GKEY", "", "gibgibCipher", "GKEY"); if (path.Length != 0) { string fileName = Path.GetFileName(path); gibgibCipher cipher = new gibgibCipher(); gibgibCipherSystem.loadCipher(cipher); loadedCipherName = fileName; lastKnowCipherName = loadedCipherName; updateLoadedCipherText(); print(cipher.cipherArray.Length); //litJsonCipherArrayClass JSONClass = litJsonCipherArrayClass.CipherArrayToCipherList(cipher); //string fileContent = LitJson.JsonMapper.ToJson(JSONClass); //string fileContent; //File.WriteAllText(path, fileContent); CipherSaveLoadManager.saveNote(cipher, path); StartCoroutine(timer(3.0f, "Successful Generate " + fileName + " file")); } else { StartCoroutine(timer(3.0f, "you dont have any key input")); } }
public static void saveNote(gibgibCipher cipher, string filename) { string Data = gibgibCipherMapperToGKEY(cipher); byte[] ba = Encoding.Default.GetBytes(Data); File.WriteAllText(filename, BitConverter.ToString(ba)); Debug.Log("kkk " + pathMixer(filename)); }
static string gibgibCipherMapperToGKEY(gibgibCipher cipher) { string outData = ""; int[,] CArray = cipher.cipherArray; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { outData += CArray[x, y] + ";"; } } return(outData); }
public static gibgibCipher LoadNote(string path) { string Data = File.ReadAllText(path); string[] arr = Data.Split('-'); byte[] array = new byte[arr.Length]; for (int i = 0; i < arr.Length; i++) { array[i] = Convert.ToByte(arr[i], 16); } string output = Encoding.Default.GetString(array); gibgibCipher saveData = gibgibCipherMapperToString(output); return(saveData); }
public static void loadCipherFromFilePath(string path) { string Data = File.ReadAllText(path); string[] arr = Data.Split('-'); byte[] array = new byte[arr.Length]; for (int i = 0; i < arr.Length; i++) { array[i] = Convert.ToByte(arr[i], 16); } string output = System.Text.Encoding.Default.GetString(array); gibgibCipher newCipher = gibgibCipherMapperToString(output); loadCipher(newCipher); }
public void OnLoadCipherButtonClick() { string path = FileBrowser.OpenSingleFile("open .GKEY file", "", "GKEY"); if (path.Length != 0) { //must use list //litJsonCipherArrayClass JSONClass = LitJson.JsonMapper.ToObject<litJsonCipherArrayClass>(fileContent.ToString()); //gibgibCipher cipher = litJsonCipherArrayClass.CipherListToCipherArray(JSONClass); gibgibCipher cipher = CipherSaveLoadManager.LoadNote(path); gibgibCipherSystem.loadCipher(cipher); loadedCipherName = Path.GetFileName(path); lastKnowCipherName = loadedCipherName; updateLoadedCipherText(); StartCoroutine(timer(3.0f, "Successful Loaded ")); } }
public static void Decrypt(string data, string password, gibgibCipher cipher, out string header, out string outPutData) { header = ""; outPutData = ""; int passwordInt = passwordStringToInt(password); gibgibCipherSystem.changeKeyWord(password); string[] splitedArray = data.Split(':'); if (splitedArray.Length != 4 || splitedArray[0] != "#GIBGIB_ENC") { outPutData = "Tried to decrypt an invalid valid GIBGIB_ENC file "; return; } string[] splitedHeaderArray = splitedArray[2].Split(' '); string[] splitedMSGArray = splitedArray[3].Split(' '); int genPassWord = Int32.Parse(splitedMSGArray[0], System.Globalization.NumberStyles.HexNumber); genPassWord /= 8233; for (int i = 0; i < splitedHeaderArray.Length; i++) { long pareseResult; string HAXHeader = splitedHeaderArray[i]; if (long.TryParse(HAXHeader, System.Globalization.NumberStyles.HexNumber, null, out pareseResult)) { header += (char)((((pareseResult) + (changeNumber(5 * i, i))) / 13)); } } for (int i = 1; i < splitedMSGArray.Length; i++) { string cipherDecryptResult = ""; string HAXMsg = splitedMSGArray[i]; if (cipher != null) { cipherDecryptResult = gibgibCipherSystem.Decrypt(HAXMsg); } else { cipherDecryptResult = HAXMsg; } long pareseResult; if (long.TryParse(cipherDecryptResult, System.Globalization.NumberStyles.HexNumber, null, out pareseResult)) { long step = (((pareseResult) + (changeNumber(17 * (i - 1), i - 1))) / 8233); long finAns = (step - passwordInt + genPassWord); if (finAns >= char.MaxValue) { finAns = 0; } outPutData += (char)finAns; } } }
public static void loadCipher(gibgibCipher newCipher) { cipher = newCipher; }
public static bool loadAndDecryptFile(string filePath, string fileName, string password, gibgibCipher cipher, out string header, out string outPutData) { header = ""; outPutData = ""; string path = filePath + fileName + ".GEC"; if (!File.Exists(path)) { return(false); } Decrypt(File.ReadAllText(path), password, cipher, out header, out outPutData); return(true); }
public static void EncryptAndSaveAsGEC(string header, string data, string password, string filePath, string fileName, gibgibCipher cipher) { string encryptedData = Encrypt(header, data, password, cipher); saveAsGEC(encryptedData, filePath, fileName); }
public static string Encrypt(string header, string data, string password, gibgibCipher cipher) { string outPutData = ""; int passwordInt = passwordStringToInt(password); gibgibCipherSystem.changeKeyWord(password); int genPassWord = rnd.Next(1, 128); outPutData += "#GIBGIB_ENC:"; outPutData += ver + ":"; if (header == null || header == "") { outPutData += "0:"; } else { for (int i = 0; i < header.Length; i++) { long newVal = (header[i] * 13) - (changeNumber(5 * i, i)); outPutData += Convert.ToString(newVal, 16) + " "; } outPutData += ":"; } outPutData += Convert.ToString(genPassWord * 8233, 16) + " "; for (int i = 0; i < data.Length; i++) { int firstStep = (data[i] + passwordInt - genPassWord) * 8233; long newVal = (firstStep) - (changeNumber(17 * i, i)); string HAXMsg = Convert.ToString(newVal, 16); string cipherEncryptResult = ""; if (cipher != null) { cipherEncryptResult = gibgibCipherSystem.Encrypt(HAXMsg); } else { cipherEncryptResult = HAXMsg; } outPutData += cipherEncryptResult + " "; } gibgibCipherSystem.changeKeyWord(""); return(outPutData); }