public static byte[] Signature(string data, DSAKey key, Encoding encoding = null)
 {
     if (encoding == null)
     {
         encoding = Encoding.UTF8;
     }
     return(Signature(encoding.GetBytes(data), key));
 }
        public static bool Verify(byte[] buffer, DSAKey key, byte[] rgbSignature)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(Verify(buffer, key.PublicKey, rgbSignature));
        }
        public static byte[] Signature(byte[] buffer, DSAKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(Signature(buffer, key.PrivateKey));
        }
 public static DSAKey CreateKey(int keySize = 1024)
 {
     using (var provider = new DSACryptoServiceProvider(keySize)) {
         var key = new DSAKey();
         var pa  = provider.ExportParameters(true);
         key.PrivateKey = provider.ToXmlString(true);
         key.PublicKey  = provider.ToXmlString(false);
         return(key);
     }
 }
        /// <summary>
        /// Create a new <see cref="DSAKey"/>
        /// </summary>
        /// <param name="keySize"></param>
        /// <returns></returns>
        public static DSAKey CreateKey(int keySize = 1024)
        {
            using var provider = new DSACryptoServiceProvider(keySize);
            var key = new DSAKey
            {
                PrivateKey = provider.ToXmlString(true),
                PublicKey  = provider.ToXmlString(false)
            };

            return(key);
        }
 /// <summary>
 /// Signature
 /// </summary>
 /// <param name="data"></param>
 /// <param name="key"></param>
 /// <param name="encoding"></param>
 /// <returns></returns>
 public static byte[] Signature(string data, DSAKey key, Encoding encoding = null)
 {
     return(Signature(encoding.SafeValue().GetBytes(data), key));
 }
 /// <summary>
 /// Signature
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="key"></param>
 /// <returns></returns>
 public static byte[] Signature(byte[] buffer, DSAKey key)
 {
     Checker.Key(key);
     return(Signature(buffer, key.PrivateKey));
 }
 /// <summary>
 /// Verify
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="key"></param>
 /// <param name="rgbSignature"></param>
 /// <returns></returns>
 public static bool Verify(byte[] buffer, DSAKey key, byte[] rgbSignature)
 {
     Checker.Key(key);
     return(Verify(buffer, key.PublicKey, rgbSignature));
 }