Exemple #1
0
        /// <summary>
        /// Encrypts a string 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 encryption</param>
        /// <returns>An encrypted byte array (64bit string)</returns>
        public byte[] Encrypt(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.Encrypt(Input, Key));
        }