public static byte[] Decrypt(byte[] data, string password, out ToxErrorDecryption error) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (password == null) { throw new ArgumentNullException(nameof(password)); } byte[] plain = new byte[data.Length - ToxEncryptionConstants.EncryptionExtraLength]; byte[] passBytes = ToxConstants.Encoding.GetBytes(password); error = ToxErrorDecryption.Ok; var success = ToxEncryptionFunctions.Pass.Decrypt(data, (uint)data.Length, passBytes, (uint)passBytes.Length, plain, ref error); if (success && error == ToxErrorDecryption.Ok) { return(plain); } return(null); }
public static byte[] DecryptData(byte[] data, ToxEncryptionKey key, out ToxErrorDecryption error) { if (data == null) throw new ArgumentNullException("data"); if (key == null) throw new ArgumentNullException("key"); byte[] output = new byte[data.Length - EncryptionExtraLength]; var pass = key.ToPassKey(); error = ToxErrorDecryption.Ok; if (!ToxEncryptionFunctions.PassKeyDecrypt(data, (uint)data.Length, ref pass, output, ref error) || error != ToxErrorDecryption.Ok) return null; return output; }
public byte[] Decrypt(byte[] data, out ToxErrorDecryption error) { if (data == null) { throw new ArgumentNullException(nameof(data)); } byte[] plain = new byte[data.Length - ToxEncryptionConstants.EncryptionExtraLength]; error = ToxErrorDecryption.Ok; var success = ToxEncryptionFunctions.Key.Decrypt(this.handle, data, (uint)data.Length, plain, ref error); if (success && error == ToxErrorDecryption.Ok) { return(plain); } return(null); }
public static byte[] DecryptData(byte[] data, string password, out ToxErrorDecryption error) { if (data == null) { throw new ArgumentNullException("data"); } if (password == null) { throw new ArgumentNullException("password"); } byte[] output = new byte[data.Length - EncryptionExtraLength]; byte[] passBytes = Encoding.UTF8.GetBytes(password); error = ToxErrorDecryption.Ok; if (!ToxEncryptionFunctions.PassDecrypt(data, (uint)data.Length, passBytes, (uint)passBytes.Length, output, ref error) || error != ToxErrorDecryption.Ok) { return(null); } return(output); }
internal static extern bool PassKeyDecrypt(byte[] data, uint length, ref ToxPassKey key, byte[] output, ref ToxErrorDecryption error);
internal static extern bool PassDecrypt(byte[] data, uint length, byte[] passphrase, uint passphraseLength, byte[] output, ref ToxErrorDecryption error);
public static extern Boolean Decrypt(ToxEncryptionKeyHandle key, Byte[] cipher, SizeT length, Byte[] plain, ref ToxErrorDecryption error);
public static extern Boolean Decrypt(Byte[] data, SizeT length, Byte[] passphrase, SizeT passphraseLength, Byte[] output, ref ToxErrorDecryption error);