Exemple #1
0
        /// <summary>
        /// Decrypts a byte array using RSA
        /// </summary>
        /// <param name="Input">
        /// Input byte array (should be small as anything over 128 bytes can not be decrypted)
        /// </param>
        /// <param name="Key">Key to use for decryption</param>
        /// <returns>A decrypted byte array</returns>
        public byte[] Decrypt(byte[] Input, string Key)
        {
            Contract.Requires <NullReferenceException>(AsymmetricAlgorithms != null, "AsymmetricAlgorithms");
            IAsymmetric Found = AsymmetricAlgorithms.FirstOrDefault();

            if (Found == null)
            {
                throw new ArgumentException("No asymmetric encryption algorithm found");
            }
            return(Found.Decrypt(Input, Key));
        }