他有这样一个JS PassGuardCtrl.js 部分代码

 
 1 defaults:{
 2             obj:null,
 3             random:null,//随机因子数
 4             hidPwdName:'password',//隐藏密码框名字,用来保存加密后的密码值
 5             outInputClass:'',//要把密码输入框写到的位置
 6             params:{//附加属性,可选
 7                 pgePath: "./ocx/",//控件文件目录
 8                 pgeId: "_ocx_password",//控件ID
 9                 pgeEdittype: 0,//控件类型,0星号,1明文
10                 pgeEreg1: "[\\s\\S]*",//输入过程中字符类型限制
11                 pgeEreg2: "[\\s\\S]{6,50}",    //输入完毕后字符类型判断条件
12                 pgeMaxlength: 50,//允许最大输入长度
13                 pgeTabindex: 2,//tab键顺序
14                 pgeClass: "ocx_style",//控件css样式
15                 pgeInstallClass: "ocx_style",//针对安装或升级
16                 pgeOnkeydown:"FormSubmit()",//回车键响应函数
17                 tabCallback:"_ocx_password2"
18             }
 
这段 js 就是对密码控件初始化.后台我在后面会把它改成  C#的
 
 
_setRandom:function(){
                if(null==this.settings.random){
                    alert("error:random is empty");
                    return false;
                }
                this.object.pwdSetSk(this.settings.random);
                return true;
            }        }
 
    pwdSetSk: function(s) {
                if (this.checkInstall()) {
                    try {
                        var control = document.getElementById(this.settings.pgeId);
                        if (this.osBrowser==1 || this.osBrowser==3 || this.osBrowser==6 || this.osBrowser==8) {
                            control.input1=s;
                        } else if (this.osBrowser==2 || this.osBrowser==4 || this.osBrowser==5) {
                            control.input(1,s);
                        }                    
                    } catch (err) {
                    }
                }                
 
 
 
这个js文件是设置安全控件的 随机因子  操作的是 安全控件的 input1
 
 
 
 
pwdResult: function() {
 
                var code = '';
 
                if (!this.checkInstall()) {
 
                    code = '';
                }
                else{    
                    try {
                        var control = document.getElementById(this.settings.pgeId);
                        if (this.osBrowser==1 || this.osBrowser==3) {
                            code = control.output1;
                        } else if (this.osBrowser==2 || this.osBrowser==4 || this.osBrowser==5) {
                            code = control.output(7);
                        }else if (this.osBrowser==6 || this.osBrowser==8) {
                            code = control.get_output1();
                        }                    
                    } catch (err) {
                        code = '';
                    }
                }
                //alert(code);
                return code;
            },
 
这个文件是我们的主角,就是当我们在安全控件中输入内容后,自动的将我们的密码加密.但是加出的密码并不是提交的那个密文,还要进行一次 BASE64加密
 
 
function setPwdVal(clazz){
    var _$=jQuery;
    _$("input."+clazz).each(function(i,n){
        var _objId = _$(n).attr("objId");
        var _code = null;
        var control = _$("#"+_objId)[0];    
        _code=window["PassGuardCtrl"+control.id.split("-")[0].toLocaleLowerCase()].pwdResult();
        //_code = Base64.encoder(_code);
        _code=BASE64.encoder(_code);
        _$(n).val(_code);
    });
}
 
在这这个方法中可以看到,使用了一次 BASE64加密,
经过上面这几个步骤后.可以将我们的密码加密成和提交时候的一样,
 
VS中添加安全控件, 大家可能都用过,基本的是 首先在工具栏右键->选择项->COM组件->选择对应的组件,OK了
 
 
 
 但是很不幸 当你把控件拖入到界面上的时候,你的VS就崩了,我用vs2005,vs2008 vs2010 vs2013 都崩没找到好的办法,只能自己手动来创建,这个估计要点功点了.
 
我估计这是控件的安全性引起VS崩溃的吧,以前做支机支付辅助也一样VS也会崩,发现这个控件其实是同一个,只是只不同的名称,(应该是 电信和移动的项目外包到同一家公司了,呵呵)
 
现在把密码和加密码方式的核心代码段贴上,
 
 
 
    public static String GetPayPass(AxPassGuardCtrlLib.AxPassGuard paypwd, String random) {
        paypwd.input1 = random;
        paypwd.edittype = 0;
        paypwd.maxlength = 50;
        paypwd.input2 = "[\\s\\S]*";//输入过程中字符类型限制
        paypwd.input13 = "[\\s\\S]{6,50}";
        String strPwd = paypwd.output1;
        paypwd.ClearSeCtrl();
        return EncodeBase64(strPwd);
    }
 
这个random 随机因子大你登陆的那个页上可以找到
 
 注意哦,这个并不是不变的,每次好像都是不一样的当你刷新页面的时候,所有我们要登陆首页先请求下登陆面把这个随机因子获取出来
 
下面是我的登陆部分方法.
 
 
 
 
        internal void Login() {
            String Result = "";
            net.Url = "https://b.bestpay.com.cn/bppf/login.do?method=login";
            net.Method = NetHelper.RequestMethod.GET;
            net.IsStream = false;
            Result = net.SendRequest();
            if (Result.StartsWith("-1")) { LastError = "无法连接服务器"; return; }
            String random = Utils.GetValue(Result, "pwdSetSk\\(\"", "\"");
            Utils.SetPassword(PassGuard, LoginPass);
 
 
            net.Url = "https://b.bestpay.com.cn/bppf/vimage.do?0." + Utils.GetUnixTime();
            net.Referer = "https://b.bestpay.com.cn/bppf/login.do?method=login";
            net.IsStream = true;
            net.Method = NetHelper.RequestMethod.GET;
            net.SendRequest();
            if (net.IOStream == null) { LastError = "获取验证码失败"; return; }
 
            Bitmap bmp = new Bitmap(net.IOStream);
            String chkCode = Captcha.GetCheckString(bmp);
            //检测验证码
            net.Url = "https://b.bestpay.com.cn/bppf/verifyCode";
            net.PostData = "verifyCode=" + chkCode;
            net.IsStream = false;
            net.Method = NetHelper.RequestMethod.POST;
            Result = net.SendRequest();
            if (Result.StartsWith("-1") || Result != "true") { LastError = "无法连接服务器"; return; }
            String LoginPwd = Utils.GetPayPass(PassGuard, random);
 
            net.Url = "https://b.bestpay.com.cn/bppf/login.do";
            net.PostData = "signature=&certSN=&toURL=&TOURL_MENUID=&sysLoginType=BPPF&username=" + MerchantId + "&password=" + LoginPwd + "&method=login&verifyCode=" + chkCode;
            net.Method = NetHelper.RequestMethod.POST;
            net.Encode = "gbk";
            net.IsStream = false;
            Result = net.SendRequest();
            LastError = Result;
            if (Result.Contains("商户ID:" + MerchantId)) {
                IsLogin = true;
                dAmt0 = Convert.ToDecimal(Utils.GetValue(Result, "账户余额:<span class=\"property-amount\">", "</span>"));
                dAmt1 = Convert.ToDecimal(Utils.GetValue(Result, "可用余额:<span class=\"property-amount\">", "</span>"));
                dAmt2 = Convert.ToDecimal(Utils.GetValue(Result, "酬金余额:<span class=\"property-amount\">", "</span>"));
                dAmt3 = Convert.ToDecimal(Utils.GetValue(Result, "冻结金额:<span class=\"property-amount\">", "</span>"));
            }
        }
 
手机充值下单方法
 
 
        internal Boolean MobilePay(Order order, ref String msg) {
            Boolean isSuccess = false;
            for (int i = 0; i < 3; i++) {
                String Result = "";
                net.Url = "https://b.bestpay.com.cn/bppf/ipos/mobilerecharge.do?method=process";
                net.Method = NetHelper.RequestMethod.POST;
                net.PostData = "mobile=" + order.Account + "&otherMoney=" + order.Price + "&moneyText=";
                net.IsStream = false;
                Result = net.SendRequest();
                if (Result.StartsWith("-1")) { continue; }
                if (!Result.Contains("请您核对好运营商信息、充值号码和金额,避免充错")) { continue; }
 
                String random = Utils.GetValue(Result, "pwdSetSk\\(\"", "\"");
                String token = Utils.GetValue(Result, "\"org.apache\\.struts\\.taglib\\.html\\.TOKEN\"", "type");
                token = Utils.GetValue(Result, "value=\"", "\"").Trim();
                String phone = Utils.GetValue(Result, "name=\"phone\" value=\"", "\"").Trim();
                String money = Utils.GetValue(Result, "name=\"money\" value=\"", "\"").Trim();
                String txnAmount = Utils.GetValue(Result, "name=\"txnAmount\" value=\"", "\"").Trim();
                String poundage = Utils.GetValue(Result, "name=\"poundage\" value=\"", "\"").Trim();
                Utils.SetPassword(PassGuard, PayPass);
 
                if (order.Account != phone) {
                    msg = "充值帐号袚篡改"; return false;
                }
                if (order.Price != money) {
                    msg = "充值金额袚篡改"; return false;
                }
 
                String PayPwd = Utils.GetPayPass(PassGuard, random);
 
                net.Url = "https://b.bestpay.com.cn/bppf/ipos/mobilerecharge.do?method=checkPayPwd&payPwd=" + PayPwd;
                net.Method = NetHelper.RequestMethod.POST;
                net.PostData = "";
                net.IsStream = false;
                Result = net.SendRequest();
                Log.Write(Result, "debut.txt");
              
 
                net.Url = "https://b.bestpay.com.cn/bppf/ipos/mobilerecharge.do?method=confirm";
                net.Method = NetHelper.RequestMethod.POST;
                net.PostData = String.Format("org.apache.struts.taglib.html.TOKEN={0}&phone={1}&money={2}&txnAmount={3}&poundage={4}&receivePhone={5}&payPwd={6}", token, phone, money, txnAmount, poundage, phone, PayPwd);
                Log.Write(net.PostData,"debug.txt");
                net.IsStream = false;
                Result = net.SendRequest();
                if(Result.Contains("充值成功")){
                    msg = "缴费下单成功";
                    return true;
                }
                msg = Utils.GetValue(Result, "充值失败原因:</span><span class=\"title\" style=\"color: red;\">", "</span>");
                Log.Write(Result, "debut.txt");
            }
            return isSuccess;
        }

C# 实现对接电信交费易自动缴费的更多相关文章

  1. C# 实现对接电信交费易自动缴费 续(winio/winring0 自动填密码)

    原文:C# 实现对接电信交费易自动缴费 续(winio/winring0 自动填密码) 自动填密码大家可能都不莫生,最有名的应该是 按键精灵 只要是一个可以输入的地方都可以能过按键精灵来完成输入.我今 ...

  2. freeswitch对接电信线路VOLTE视频通话

    在public.xml上设置视频编码: <action application="export" data="nolocal:absolute_codec_stri ...

  3. 那些年,我们开发的接口之:QQ登录(OAuth2.0)

    那些年,我们开发的接口之:QQ登录(OAuth2.0) 吴剑 2013-06-14 原创文章,转载必须注明出处:http://www.cnblogs.com/wu-jian 前言 开发这些年,做过很多 ...

  4. Immutable Object模式

    多线程共享变量的情况下,为了保证数据一致性,往往需要对这些变量的访问进行加锁.而锁本身又会带来一些问题和开销.Immutable Object模式使得我们可以在不使用锁的情况下,既保证共享变量访问的线 ...

  5. QQ登录(OAuth2.0)

    QQ登录(OAuth2.0) 那些年,我们开发的接口之:QQ登录(OAuth2.0) 吴剑 2013-06-14 原创文章,转载必须注明出处:http://www.cnblogs.com/wujian ...

  6. 盘点和反思在微信的阴影下艰难求生的移动端IM应用

    本文原作者:李越,由银杏财经原创发布,本次内容改动. 1.前言 上线一周完成1.5亿元融资,上线10天总激活用户数超400万,8月29日单日新增用户超100万,这是子弹短信交出的最新成绩单(详见< ...

  7. Java多线程编程模式实战指南(二):Immutable Object模式

    多线程共享变量的情况下,为了保证数据一致性,往往需要对这些变量的访问进行加锁.而锁本身又会带来一些问题和开销.Immutable Object模式使得我们可以在不使用锁的情况下,既保证共享变量访问的线 ...

  8. .NET RSA解密、签名、验签

    using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Sec ...

  9. 浅谈WebService的调用<转>

    0.前言 前段时间,公司和电信有个合作,产品对接电信的某个平台,使用了WebService接口的调用,实现了业务受理以及单点登录.终于使用到了WebService,楼主还是比较兴奋的,目前功能已经上线 ...

随机推荐

  1. android 开发 获取各种intent (图片、apk文件、excel、pdf等文件)

    public static Intent openFile(String filePath){ File file = new File(filePath); if(!file.exists()) r ...

  2. 生成最小树prim算法

    最小生成树prim算法实现   ‘      ’最小生成树,就是权值(两点间直线的值)之和的最小值. 首先,要用二维数组记录点和权值.如上图所示无向图: int G[6][6];       G[1] ...

  3. 【读书笔记】Redis入门

    1:Redis概览 Remote Dictionary Server 远程字典服务 Redis是基于内存的存储 在一台普通的笔记本上,Redis每秒的读取速度可以达到10万 内存读取数据,断电的时候数 ...

  4. c++ 原子操作

    转载自: http://blog.csdn.net/yockie/article/details/8838686 所谓的原子操作,取的就是“原子是最小的.不可分割的最小个体”的意义,它表示在多个线程访 ...

  5. WEB前端常用的测试工具

    一.QUnit 前端测试工具 QUnit是一个强大的JavaScript单元测试框架,该框架是由jQuery团队的成员所开发,并且是jQuery的官方测试套件.Qunit是Jquery的单元测试框架, ...

  6. Matlab中find函数的使用

    一.问题来源 看到了 min_score_pos = find(A0_scores==min(A0_scores), 1); [r,c] = find(X,k),返回X中第k个非零元素的行列位置. 二 ...

  7. java 正则匹配空格字符串 正则表达式截取字符串

    java 正则匹配空格字符串 正则表达式截取字符串 需求:从一堆sql中取出某些特定字符串: 比如配置的sql语句为:"company_code = @cc and project_id = ...

  8. 轻轻修改配置文件完成 OpenStack 监控

    当我们使用虚拟化云平台 OpenStack 时,必然要时时监控其虚拟机性能,随着近年企业级数据中心的不断发展,像混合虚拟化环境的业务需求也在持续增长中,因而也随之带来的监控需求更显重要,所以小编带来一 ...

  9. Linked List vs Array

    Both Arrays and Linked List can be used to store linear data of similar types, but they both have so ...

  10. Asp.net MVC4.0自定义Html辅助方法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...