Esempio n. 1
0
        private trafficMessage SignMessageBeforePost(trafficMessage msgSource)
        {
            trafficMessage msgEncrypt = new trafficMessage();


            //获取报文字符集
            this.encodeCode     = Encoding.GetEncoding(msgSource.charset);
            msgEncrypt.charset  = msgSource.charset;
            msgEncrypt.signType = msgSource.signType;
            msgEncrypt.extend   = msgSource.extend;
            msgEncrypt.data     = msgSource.data;

            //报文签名
            msgEncrypt.sign = CryptUtils.Base64Encoder(CryptUtils.CreateSignWithPrivateKey(CryptUtils.getBytesFromString(msgSource.data, encodeCode),
                                                                                           CryptUtils.getPrivateKeyXmlFromPFX(pfxFilePath, pfxPassword)));
            return(msgEncrypt);
        }
Esempio n. 2
0
        private trafficMessage CheckSignMessageAfterResponse(trafficMessage msgEncrypt)
        {
            trafficMessage msgSource = new trafficMessage();

            //获取报文字符集
            this.encodeCode    = Encoding.GetEncoding(msgEncrypt.charset);
            msgSource.charset  = msgEncrypt.charset;
            msgSource.signType = msgEncrypt.signType;
            msgSource.extend   = msgEncrypt.extend;
            msgSource.data     = msgEncrypt.data;

            msgSource.sign = CryptUtils.VerifySignWithPublicKey(
                (CryptUtils.getBytesFromString(msgEncrypt.data, encodeCode)),
                CryptUtils.getPublicKeyXmlFromCer(cerFilePath),
                CryptUtils.Base64Decoder(msgEncrypt.sign)
                ).ToString();
            return(msgSource);
        }