//verschlüsseln private static void EncryptChunk(string input, string output) { GCHandle gch = GCHandle.Alloc(AESPassword, GCHandleType.Pinned); DycryptionForChunks.FileEncrypt(input, output, AESPassword); }
public static void DycryptAllChunk() { GCHandle gch = GCHandle.Alloc(AESPassword, GCHandleType.Pinned); string CmpChnkPath = Directory.GetCurrentDirectory() + @"\Data\"; allCmpChnkFullPath = Directory.GetFiles(CmpChnkPath); allCmpChnkFilenames = allCmpChnkFullPath; allCmpChnkRAWNames = allCmpChnkFullPath; for (int i = 0; i < allCmpChnkFilenames.Length; i++) { ChunkLogger.LOGIT("allCmpChnkFilenames: " + allCmpChnkFilenames[i]); ChunkLogger.LOGIT("allCmpChnkFullPath: " + allCmpChnkFullPath[i]); } for (int i = 0; i < allCmpChnkFilenames.Length; i++) { allCmpChnkFilenames[i] = Path.GetFileName(allCmpChnkFilenames[i]); ChunkLogger.LOGIT("Filename: " + allCmpChnkFilenames[i]); } char[] seperator; seperator = ".".ToCharArray(); //Encryption for (int i = 0; i < allCmpChnkFilenames.Length; i++) { ChunkLogger.LOGIT("Format: " + allCmpChnkFilenames[i]); string[] splitStorage = allCmpChnkFilenames[i].Split(seperator); ChunkLogger.LOGIT("AFTER SPLIT Format: " + allCmpChnkFilenames[i]); for (int x = 0; x < splitStorage.Length; x++) { ChunkLogger.LOGIT("Splited: " + splitStorage[x]); } allCmpChnkRAWNames[i] = splitStorage[0] + "." + splitStorage[1] + "." + splitStorage[2]; ChunkLogger.LOGIT(""); ChunkLogger.LOGIT("RAW Name: " + allCmpChnkRAWNames[i]); ChunkLogger.LOGIT("Filename: " + allCmpChnkFilenames[i]); ChunkLogger.LOGIT("1st Path: " + CmpChnkPath + allCmpChnkFilenames[i]); ChunkLogger.LOGIT("2nd Path: " + CmpChnkPath); ChunkLogger.LOGIT("Password: "******""); DycryptionForChunks.FileDecrypt(CmpChnkPath + allCmpChnkRAWNames[i] + ".CmpChnk", CmpChnkPath + allCmpChnkRAWNames[i] + ".CommpressedChunk", AESPassword); } //unzipping ChunkLogger.LOGIT("Extracting"); for (int i = 0; i < allCmpChnkFullPath.Length; i++) { ChunkLogger.LOGIT("Extracting: " + allCmpChnkFilenames[i] + ".CommpressedChunk" + " | Target Folder: " + allCmpChnkRAWNames[i]); Directory.CreateDirectory(CmpChnkPath + allCmpChnkRAWNames[i]); ChunkGenerator.ZipToChunk.ExtractZipFile(CmpChnkPath + allCmpChnkRAWNames[i] + ".CommpressedChunk", ZipPassword, CmpChnkPath + allCmpChnkRAWNames[i]); } wait.waitSec(2); ChunkLogger.LOGIT("Deleting junk"); for (int i = 0; i < allCmpChnkRAWNames.Length; i++) { ChunkLogger.LOGIT("operation " + (i + 1) + " of " + (allCmpChnkRAWNames.Length + 1)); ChunkLogger.LOGIT("Deleting: " + CmpChnkPath + allCmpChnkRAWNames[i] + ".CmpChnk"); //File.Delete(CmpChnkPath + allCmpChnkRAWNames[i] + ".CmpChnk"); ChunkLogger.LOGIT("Deleting" + CmpChnkPath + allCmpChnkRAWNames[i] + ".CommpressedChunk"); File.Delete(CmpChnkPath + allCmpChnkRAWNames[i] + ".CommpressedChunk"); } }