예제 #1
0
        public static async Task <byte[]> ExtractUserDataFile(string sourcePath, string destinationPath, byte[] key,
                                                              byte[] iv)
        {
            NDirectory.CreateMissingDirs(destinationPath);

            await using var src  = new FileStream(sourcePath, FileMode.Open, FileAccess.Read);
            await using var dest = new FileStream(destinationPath, FileMode.Create, FileAccess.Write);

            using var decryptor       = QuickAesTransform.CreateDecryptor(key, iv);
            await using var srcCrypto = new CryptoStream(src, decryptor, CryptoStreamMode.Read);

            var hash = await srcCrypto.CopyToCreateHashAsync(dest);

            return(hash);
        }