Beispiel #1
0
        public Stream Encrypt(Stream inputStream, string fileName, DateTime fileDateTime)
        {
            if ((_ShareType != SecretShareType.File) || (_PassPhrase == null))
            {
                throw new InvalidOperationException("Cannot encrypt file unless share is file type");
            }

            return(OpenPgp.EncryptSingleFile(_PassPhrase, inputStream, fileName, fileDateTime));
        }
Beispiel #2
0
        public Stream Decrypt(Stream inputStream, out string originalFileName, out DateTime originalDateTime)
        {
            if (ShareType != SecretShareType.File)
            {
                throw new InvalidOperationException("Secret must be of the File type to decrypt file");
            }

            var passPhrase = new SecureString();

            foreach (var currentNibble in RecoveredHexString)
            {
                passPhrase.AppendChar(currentNibble);
            }

            return(OpenPgp.DecryptSingleFile(inputStream, passPhrase, out originalFileName, out originalDateTime));
        }