<commit_before>using System;
using System.Diagnostics;
using static Interop.Libsodium;

namespace NSec.Cryptography
{
    [DebuggerDisplay("Algorithm = {Algorithm}")]
    public sealed class Key
    {
        private readonly Algorithm _algorithm;
        private readonly KeyFlags _flags;
        private readonly SecureMemoryHandle _handle;
        private readonly PublicKey _publicKey;

        private bool _exported;

        public Key(
            Algorithm algorithm,
            KeyFlags flags = KeyFlags.None)
        {
            if (algorithm == null)
                throw new ArgumentNullException(nameof(algorithm));

            _algorithm = algorithm;
            _flags = flags;
            _handle = algorithm.CreateKey(out _publicKey);
            _handle.MakeReadOnly();
        }

        internal Key(
            Algorithm algorithm,
            KeyFlags flags,
            SecureMemoryHandle handle,
            PublicKey publicKey)<commit_msg>Implement IDisposable<commit_after>using System;
using System.Diagnostics;
using static Interop.Libsodium;

namespace NSec.Cryptography
{
    [DebuggerDisplay("Algorithm = {Algorithm}")]
    public sealed class Key : IDisposable
    {
        private readonly Algorithm _algorithm;
        private readonly KeyFlags _flags;
        private readonly SecureMemoryHandle _handle;
        private readonly PublicKey _publicKey;

        private bool _exported;

        public Key(
            Algorithm algorithm,
            KeyFlags flags = KeyFlags.None)
        {
            if (algorithm == null)
                throw new ArgumentNullException(nameof(algorithm));

            _algorithm = algorithm;
            _flags = flags;
            _handle = algorithm.CreateKey(out _publicKey);
            _handle.MakeReadOnly();
        }

        internal Key(
            Algorithm algorithm,
            KeyFlags flags,
            SecureMemoryHandle handle,
            PublicKey publicKey)
{'fraction_non_alphanumeric': 0.060590631364562116, 'fraction_numerical': 0.0, 'mean_word_length': 2.079937304075235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2814863', 'n_tokens_mistral': 470, 'n_tokens_neox': 451, 'n_words': 131}