Example #1
0
        private void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // dispose managed state (managed objects).
                    this.handle.Dispose();
                    this.handle = null;
                }

                // free unmanaged resources (unmanaged objects) and override a finalizer below.

                disposed = true;
            }
        }
Example #2
0
        public ToxEncryptionKey(string passphrase, byte[] salt = null)
        {
            if (string.IsNullOrEmpty(passphrase))
            {
                throw new ArgumentException(nameof(passphrase));
            }

            ToxErrorKeyDerivation error;
            var handle = salt == null?Derive(passphrase, out error) : Derive(passphrase, salt, out error);

            if (handle == null || error != ToxErrorKeyDerivation.Ok)
            {
                throw new Exception("Could not derive key from passphrase");
            }

            this.handle = handle;
        }
 public static extern Boolean Decrypt(ToxEncryptionKeyHandle key, Byte[] cipher, SizeT length, Byte[] plain, ref ToxErrorDecryption error);