private ICryptoTransform GetDecryptor(SymmetricAlgorithm algorithm) { byte[] ivBytes = IV.ToByteArray(); byte[] keyBytes = GetPasswordBytes(); return(algorithm.CreateDecryptor(keyBytes, ivBytes)); }
public IBuffer GetBufferWithoutHMAC() { bool usesPassword = (Options & (byte)1) == (byte)1; using (var ms = new MemoryStream((int)(HEADER_LENGTH + CipherText.Length))) using (var writer = new BinaryWriter(ms)) { writer.Write(Version); writer.Write(Options); if (usesPassword) { writer.Write(EncryptionSalt.ToByteArray()); writer.Write(HMACSalt.ToByteArray()); } writer.Write(IV.ToByteArray()); writer.Write(CipherText.ToByteArray()); return(ms.ToArray().ToBuffer()); } }