// Token: 0x06000188 RID: 392 RVA: 0x00005190 File Offset: 0x00003390 public void Encrypt(ReadOnlySpan <byte> source, Span <byte> target, ReadOnlySpan <byte> nonce) { if (nonce.Length != Interop.SodiumNonceSize) { throw new ArgumentException(string.Format("Invalid nonce size. Nonce needs to have a length of {0} bytes.", Interop.SodiumNonceSize), "nonce"); } if (target.Length != Interop.SodiumMacSize + source.Length) { throw new ArgumentException(string.Format("Invalid target buffer size. Target buffer needs to have a length that is a sum of input buffer length and Sodium MAC size ({0} bytes).", Interop.SodiumMacSize), "target"); } int num; if ((num = Interop.Encrypt(source, target, this.Key.Span, nonce)) != 0) { throw new CryptographicException(string.Format("Could not encrypt the buffer. Sodium returned code {0}.", num)); } }
public void Encrypt(ReadOnlySpan <byte> source, Span <byte> target, ReadOnlySpan <byte> nonce) { if (nonce.Length != Interop.SodiumNonceSize) { throw new ArgumentException($"Invalid nonce size. Nonce needs to have a length of {Interop.SodiumNonceSize} bytes.", nameof(nonce)); } if (target.Length != Interop.SodiumMacSize + source.Length) { throw new ArgumentException($"Invalid target buffer size. Target buffer needs to have a length that is a sum of input buffer length and Sodium MAC size ({Interop.SodiumMacSize} bytes).", nameof(target)); } int result; if ((result = Interop.Encrypt(source, target, this.Key.Span, nonce)) != 0) { throw new CryptographicException($"Could not encrypt the buffer. Sodium returned code {result}."); } }