/// <summary> /// RSA Build Sign /// </summary> /// <param name="s"></param> /// <param name="k">PrivateKey</param> /// <param name="_CK"></param> /// <returns></returns> public static string BuildSign(this string s, string k, CipherKind _CK = CipherKind.RSA2) { if (_CK == CipherKind.RSA) { return(Convert.ToBase64String(k.DecodeRSAKey(1024).SignData(Encoding.UTF8.GetBytes(s), "SHA1"))); } else { return(Convert.ToBase64String(k.DecodeRSAKey(2048).SignData(Encoding.UTF8.GetBytes(s), "SHA256"))); } }
/// <summary> /// build clear text /// </summary> /// <param name="s"></param> /// <param name="k"></param> /// <param name="_CK"></param> /// <returns></returns> public static bool VerifySign(this string s, string k, string sign, CipherKind _CK = CipherKind.RSA2) { var _ICM = Activator.CreateInstance(Type.GetType("BCL.ToolLib.Modules.CipherModule_" + _CK.ToString())) as ICipherModule; return(_ICM.VerifySign(s, k, sign)); }
/// <summary> /// build clear text /// </summary> /// <param name="s"></param> /// <param name="k"></param> /// <param name="_CK"></param> /// <returns></returns> public static string BuildClear(this string s, string k, CipherKind _CK = CipherKind.DES) { var _ICM = Activator.CreateInstance(Type.GetType("BCL.ToolLib.Modules.CipherModule_" + _CK.ToString())) as ICipherModule; return(_ICM.BuildClear(s, k)); }