开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 6936|回复: 19
收起左侧

[完成] 这段rsa加密的js代码怎么用?

 关闭 [复制链接]
结帖率:100% (8/8)
发表于 2014-8-15 17:36:43 | 显示全部楼层 |阅读模式   山东省菏泽市
5精币
  1. function RSAKey() {
  2.         this.n = null;
  3.         this.e = 0;
  4.         this.d = null;
  5.         this.p = null;
  6.         this.q = null;
  7.         this.dmp1 = null;
  8.         this.dmq1 = null;
  9.         this.coeff = null
  10. }
  11. function RSASetPublic(b, a) {
  12.         if (b != null && a != null && b.length > 0 && a.length > 0) {
  13.                 this.n = parseBigInt(b, 16);
  14.                 this.e = parseInt(a, 16)
  15.         } else {
  16.                 alert("Invalid RSA public key")
  17.         }
  18. }
  19. function RSADoPublic(a) {
  20.         return a.modPowInt(this.e, this.n)
  21. }
  22. function RSAEncrypt(f) {
  23.         var a = pkcs1pad2(f, (this.n.bitLength() + 7) >> 3);
  24.         if (a == null) {
  25.                 return null
  26.         }
  27.         var g = this.doPublic(a);
  28.         if (g == null) {
  29.                 return null
  30.         }
  31.         var d = g.toString(16).toUpperCase();
  32.         var e = 256 - d.length;
  33.         for (var b = 0; b < e; b = b + 1) {
  34.                 d = "0" + d
  35.         }
  36.         return d
  37. }
  38. RSAKey.prototype.doPublic = RSADoPublic;
  39. RSAKey.prototype.setPublic = RSASetPublic;
  40. RSAKey.prototype.encrypt = RSAEncrypt;
  41. var b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  42. var b64pad = "=";

  43. function hex2b64(d) {
  44.         var b;
  45.         var e;
  46.         var a = "";
  47.         for (b = 0; b + 3 <= d.length; b += 3) {
  48.                 e = parseInt(d.substring(b, b + 3), 16);
  49.                 a += b64map.charAt(e >> 6) + b64map.charAt(e & 63)
  50.         }
  51.         if (b + 1 == d.length) {
  52.                 e = parseInt(d.substring(b, b + 1), 16);
  53.                 a += b64map.charAt(e << 2)
  54.         } else {
  55.                 if (b + 2 == d.length) {
  56.                         e = parseInt(d.substring(b, b + 2), 16);
  57.                         a += b64map.charAt(e >> 2) + b64map.charAt((e & 3) << 4)
  58.                 }
  59.         }
  60.         while ((a.length & 3) > 0) {
  61.                 a += b64pad
  62.         }
  63.         return a
  64. }
  65. function b64tohex(e) {
  66.         var c = "";
  67.         var d;
  68.         var a = 0;
  69.         var b;
  70.         for (d = 0; d < e.length; ++d) {
  71.                 if (e.charAt(d) == b64pad) {
  72.                         break
  73.                 }
  74.                 v = b64map.indexOf(e.charAt(d));
  75.                 if (v < 0) {
  76.                         continue
  77.                 }
  78.                 if (a == 0) {
  79.                         c += int2char(v >> 2);
  80.                         b = v & 3;
  81.                         a = 1
  82.                 } else {
  83.                         if (a == 1) {
  84.                                 c += int2char((b << 2) | (v >> 4));
  85.                                 b = v & 15;
  86.                                 a = 2
  87.                         } else {
  88.                                 if (a == 2) {
  89.                                         c += int2char(b);
  90.                                         c += int2char(v >> 2);
  91.                                         b = v & 3;
  92.                                         a = 3
  93.                                 } else {
  94.                                         c += int2char((b << 2) | (v >> 4));
  95.                                         c += int2char(v & 15);
  96.                                         a = 0
  97.                                 }
  98.                         }
  99.                 }
  100.         }
  101.         if (a == 1) {
  102.                 c += int2char(b << 2)
  103.         }
  104.         return c
  105. }
  106. function b64toBA(e) {
  107.         var d = b64tohex(e);
  108.         var c;
  109.         var b = new Array();
  110.         for (c = 0; 2 * c < d.length; ++c) {
  111.                 b[c] = parseInt(d.substring(2 * c, 2 * c + 2), 16)
  112.         }
  113.         return b
  114. };

  115. function rsaPwd(c) {
  116.         var b = new RSAKey();
  117.         b.setPublic(toaPublicKey, "10001");
  118.         var a = b.encrypt(c);
  119.         return a
  120. };
复制代码
toaPublicKey是:BB955F6C6185B341C1A42EBF1FF9971B273878DBDAB252A0F1C305EBB529E116D807E0108BE6EDD47FF8DC5B6720FFE7F413CBB4ACDFB4C6BE609A5D60F5ADB261690A77755E058D4D9C0EC4FC2F5EB623DEBC88896003FBD8AFC4C3990828C66062A6D6CE509A2B0F8E06C4E332673FB86D235164B62B6110C1F1E0625B20ED

c应该是密码,a应该是加密结果,用脚本组件不行,我不太懂JS,哪位帮忙看一下,该怎么用啊


补充内容 (2014-8-15 17:45):
完整js代码在3楼

补充内容 (2014-8-15 17:51):
网站地址:https://passport.wanlitong.com/pass-info/oauth2/login.view?client_id=IN_000002&redirect_uri=http%3A%2F%2Fgame.wanlitong.com%2F%3Fact%3Dlogin%26st%3DloginCallback%26go_url%3DaHR0cDovL2dhbW...

补充内容 (2014-8-15 17:52):
上面的不行,这个吧http://game.wanlitong.com/?act=login&_time=1408093525015

最佳答案

查看完整内容

值是变动的。。 。 补充内容 (2014-8-15 18:18): 诶嘛 给精币。
结帖率:100% (7/7)
发表于 2014-8-15 17:36:44 | 显示全部楼层   广东省湛江市
RSA.zip (7.03 KB, 下载次数: 173)

评分

参与人数 1精币 +1 收起 理由
lovinlik + 1 感谢分享,很给力!~

查看全部评分

回复

使用道具 举报

结帖率:0% (0/1)
发表于 2014-8-15 17:38:54 | 显示全部楼层   江西省赣州市
{JS完整吗?
回复

使用道具 举报

结帖率:100% (8/8)
 楼主| 发表于 2014-8-15 17:43:16 | 显示全部楼层   山东省菏泽市

不完整,整段太长了,我看能补上吗

点评

这个JS加密的密码登陆不上的话, 请站内私信我,   广东省湛江市  发表于 2014-8-15 18:22
回复

使用道具 举报

结帖率:100% (8/8)
 楼主| 发表于 2014-8-15 17:45:11 | 显示全部楼层   山东省菏泽市
js.rar (5.24 KB, 下载次数: 66)
回复

使用道具 举报

结帖率:100% (8/8)
 楼主| 发表于 2014-8-15 17:45:33 | 显示全部楼层   山东省菏泽市
完整js代码在3楼
回复

使用道具 举报

结帖率:0% (0/1)
发表于 2014-8-15 17:46:15 | 显示全部楼层   江西省赣州市

什么网站的?
回复

使用道具 举报

结帖率:100% (7/7)
发表于 2014-8-15 17:46:43 | 显示全部楼层   广东省湛江市
来个链接~  方便查看啊 ,亲。
回复

使用道具 举报

结帖率:100% (8/8)
 楼主| 发表于 2014-8-15 17:50:59 | 显示全部楼层   山东省菏泽市
a398496800 发表于 2014-8-15 17:46
来个链接~  方便查看啊 ,亲。

https://passport.wanlitong.com/pass-info/oauth2/login.view?client_id=IN_000002&redirect_uri=http%3A%2F%2Fgame.wanlitong.com%2F%3Fact%3Dlogin%26st%3DloginCallback%26go_url%3DaHR0cDovL2dhbWUud2FubGl0b25nLmNvbS8%2FYWN0PWFjdF9lZ2dicmVhayZ0cmFja191PWNwc2oy&response_type=code&state=_20140815170545925122&platform=WEB&otherLogin=QQ%7CALIPAY%7CWEIBO
回复

使用道具 举报

结帖率:100% (8/8)
 楼主| 发表于 2014-8-15 17:51:22 | 显示全部楼层   山东省菏泽市

https://passport.wanlitong.com/pass-info/oauth2/login.view?client_id=IN_000002&redirect_uri=http%3A%2F%2Fgame.wanlitong.com%2F%3Fact%3Dlogin%26st%3DloginCallback%26go_url%3DaHR0cDovL2dhbWUud2FubGl0b25nLmNvbS8%2FYWN0PWFjdF9lZ2dicmVhayZ0cmFja191PWNwc2oy&response_type=code&state=_20140815170545925122&platform=WEB&otherLogin=QQ%7CALIPAY%7CWEIBO
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表