/// <summary> /// Encrypts the specified plain text using the default credential. /// </summary> /// <param name="crypto">An <see cref="ICrypto"/>.</param> /// <param name="plainText">The plain text.</param> /// <returns>The encrypted value as a byte array.</returns> public static byte[] Encrypt(this ICrypto crypto, byte[] plainText) => crypto?.Encrypt(plainText, null) ?? throw new ArgumentNullException(nameof(crypto));
/// <summary> /// Encrypts the plaintext using an internal private key. /// </summary> /// <param name="plaintext">The text to encrypt.</param> /// <returns>An encrypted string in base64 format.</returns> public static string Encrypt(string plaintext) { return(_provider.Encrypt(plaintext)); }
/// <summary> /// Encrypts the URL safe. /// </summary> /// <param name="value">The value.</param> /// <returns>System.String.</returns> public string EncryptUrlSafe(string value) { var encrypt = _crypto.Encrypt(value); return(HttpServerUtility.UrlTokenEncode(Encoding.Default.GetBytes(encrypt))); }
public ActionResult CheckPassword(string password) { var user = _login.VerifyLogin(GetUser().UserName, _crypto.Encrypt(password, true)); return(Json(new { Result = !(user == null), Message = "" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Returns an encrypted string from given value. /// </summary> private static string GetEncryptedValue(string value) { return(Crypto.Encrypt(value)); }