public static void decryptFile(int p, int q, int sizeOfBlock, string iFileName, string oFileName) { var blocks = SplitFile.GetBlocksFromFile(iFileName, sizeOfBlock, false); List <BigInteger> newBlocks = new List <BigInteger>(); for (int i = 0; i < blocks.Length; i++) { var c = blocks[i]; var m = decrypt(p, q, c.IntValue()); //newBlocks.Add(m); } SplitFile.WriteBlocksToFile(oFileName, newBlocks.ToArray(), sizeOfBlock, true); }
public static void cryptFile(int p, int q, int sizeOfBlock, string iFileName, string oFileName) { int n = p * q; var blocks = SplitFile.GetBlocksFromFile(iFileName, sizeOfBlock, true); List <BigInteger> newBlocks = new List <BigInteger>(); foreach (var m in blocks) { newBlocks.Add(crypt(n, m.IntValue())); } SplitFile.WriteBlocksToFile(oFileName, newBlocks.ToArray(), sizeOfBlock, false); }
public static void decryptFile(BigInteger p, BigInteger x, int sizeOfBlock, string iFileName, string oFileName) { var blocks = SplitFile.GetBlocksFromFile(iFileName, sizeOfBlock * 2, false); List <BigInteger> newBlocks = new List <BigInteger>(); for (int i = 0; i < blocks.Length; i += 2) { var a = blocks[i]; var b = blocks[i + 1]; BigInteger m = decrypt(p, x, a, b); newBlocks.Add(m); } SplitFile.WriteBlocksToFile(oFileName, newBlocks.ToArray(), sizeOfBlock, true); }
public static void TestSplitFile() { //string fileName1 = @"C:\Users\Vladimir\Desktop\Новая папка\Новый текстовый документ (1).txt"; string fileName1 = @"C:\Users\Vladimir\Desktop\Новая папка\08140-Kurukafa.jpg"; string fileName2 = @"C:\Users\Vladimir\Desktop\Новая папка\Новый текстовый документ (2).txt"; //string fileName3 = @"C:\Users\Vladimir\Desktop\Новая папка\Новый текстовый документ (3).txt"; string fileName3 = @"C:\Users\Vladimir\Desktop\Новая папка\result.jpg"; int bytesInBlock = 128; var bytes1 = SplitFile.GetBlocksFromFile(fileName1, bytesInBlock, true); SplitFile.WriteBlocksToFile(fileName2, bytes1, bytesInBlock, false); var bytes2 = SplitFile.GetBlocksFromFile(fileName2, bytesInBlock, false); SplitFile.WriteBlocksToFile(fileName3, bytes2, bytesInBlock, true); }
public static void cryptFile(BigInteger p, BigInteger g, BigInteger x, int sizeOfBlock, string iFileName, string oFileName) { long i = 0; var y = g.modPow(x, p); var blocks = SplitFile.GetBlocksFromFile(iFileName, sizeOfBlock, true); List <BigInteger> newBlocks = new List <BigInteger>(); foreach (var m in blocks) { BigInteger k = (Rand() % (p - 1) + 1); BigInteger a; BigInteger b; crypt(p, g, y, m, out a, out b); newBlocks.Add(a); newBlocks.Add(b); } SplitFile.WriteBlocksToFile(oFileName, newBlocks.ToArray(), sizeOfBlock * 2, false); }