Example #1
0
        /// <summary>
        /// Encrypt data from <see cref="string"/> to base64 <see cref="string"/> using <see cref="Convert.ToBase64String(byte[])"/> and <see cref="Encoding"/>
        /// </summary>
        /// <param name="encryptor">Specific encryptor</param>
        /// <param name="data">String data for encryption</param>
        /// <param name="encoding">Encoding for conversion <see cref="string"/> to byte[]</param>
        /// <returns>Encrypted base64 string data</returns>
        public static string EncryptStringToBase64String(this IEncryptor encryptor, string data, Encoding encoding)
        {
            encoding.NullValidate(nameof(encoding));

            var byteData = encoding.GetBytes(data);

            return(encryptor.EncryptToBase64String(byteData));
        }