public void DecryptData(Stream input, Stream output) { GOST28147_89 gost = new GOST28147_89(); gost.SetOptimTable(); byte[] decryptedData = new byte[8]; int cnt = 0; input.Position = 0; while ((cnt = input.Read(decryptedData, 0, 8)) != 0) { decryptedData = gost.GOSTDataDecrypt(decryptedData); output.Write(decryptedData, 0, decryptedData.Length); decryptedData = new byte[8]; } }
public void EncryptData(Stream input, Stream output) { GOST28147_89 gost = new GOST28147_89(); gost.SetOptimTable(); byte[] encryptedData = new byte[4]; int cnt = 0; input.Position = 0; while ((cnt = input.Read(encryptedData, 0, 4)) != 0) { for (; cnt < 4; ++cnt) { encryptedData[cnt] = 0; } encryptedData = gost.GOSTDataCrypt(encryptedData); output.Write(encryptedData, 0, encryptedData.Length); encryptedData = new byte[4]; } }