/// <summary>
        /// Decrypts the input.
        /// </summary>
        /// <param name="input">the bytes to decrypt.</param>
        /// <returns>decrypted bytes</returns>
        /// <exception cref="ArgumentNullException">if <paramref name="input"/> is null or Length == 0.</exception>
        public override byte[] DecryptValue(byte[] input)
        {
            if (input == null || input.Length == 0)
            {
                throw LogHelper.LogArgumentNullException(nameof(input));
            }

            return(_rsa.DecryptValue(input));
        }
Beispiel #2
0
 public static byte[] Decrypt(byte[] bytes, string privateKey)
 {
     using (var rsa = new RSACryptoServiceProvider())
     {
         rsa.FromXmlString(privateKey);
         var retBytes = rsa.DecryptValue(bytes);
         return(retBytes);
     }
 }
        /// <summary>
        /// RSA public key is decrypted
        /// </summary>
        /// <param name="dataBytes">Need to decrypt the data</param>
        /// <returns></returns>
        public string DecryptByPublicKey(byte[] dataBytes)
        {
            if (PublicRsa is null)
            {
                throw new ArgumentException("public key can not null");
            }

            var resBytes = PublicRsa.DecryptValue(dataBytes);

            return(DataEncoding.GetString(resBytes));
        }