Example #1
0
        public static string encryptPin(string card, string pwd, string encoding, string EncryptCert)
        {
            byte[] numArray = SecurityUtil.pin2PinBlockWithCardNO(pwd, card);
            SignUtil.printHexString(numArray);
            X509Certificate2         x509Certificate2         = new X509Certificate2(EncryptCert);
            RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider();

            rSACryptoServiceProvider = (RSACryptoServiceProvider)x509Certificate2.PublicKey.Key;
            return(Convert.ToBase64String(rSACryptoServiceProvider.Encrypt(numArray, false)));
        }
Example #2
0
        public static bool Sign(Dictionary <string, string> data, Encoding encoder, string signCertpath, string signCertpwd)
        {
            data["certId"] = CertUtil.GetSignCertId(signCertpath, signCertpwd);
            string str = SignUtil.CoverDictionaryToString(data);

            byte[] numArray = SecurityUtil.Sha1X16(str, encoder);
            string lower    = BitConverter.ToString(numArray).Replace("-", "").ToLower();

            byte[] numArray1 = SecurityUtil.SignBySoft(CertUtil.GetSignProviderFromPfx(signCertpath, signCertpwd), encoder.GetBytes(lower));
            data["signature"] = Convert.ToBase64String(numArray1);
            return(true);
        }
Example #3
0
        public static bool Validate(Dictionary <string, string> data, Encoding encoder, string validateCertdir)
        {
            bool flag;

            byte[] numArray = Convert.FromBase64String(data["signature"]);
            data.Remove("signature");
            byte[] numArray1 = SecurityUtil.Sha1X16(SignUtil.CoverDictionaryToString(data), encoder);
            string lower     = BitConverter.ToString(numArray1).Replace("-", "").ToLower();
            RSACryptoServiceProvider validateProviderFromPath = CertUtil.GetValidateProviderFromPath(data["certId"], validateCertdir);

            flag = (null != validateProviderFromPath ? SecurityUtil.ValidateBySoft(validateProviderFromPath, numArray, encoder.GetBytes(lower)) : false);
            return(flag);
        }