pptv.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var CryptoJS = require("crypto-js");
  2. // const msg = "type=mhpptv&appId=pptv.web.h5&appPlt=web&appVer=1.0.4&channel=sn.cultural&sdkVer=1.5.0&cid=23764751&allowFt=0,1,2,3&rf=0&ppi=302c393939&o=www.google.com&ahl_ver=1&ahl_random=56512723466a41555e402b327439736b&ahl_signa=9d6e29f58acde65886d26d364cb0c57145e57fcd8f430fdd3abea0795477937a&vvId=a88a33b5-5644-9435-6e95-b5f34b20c3d6&version=1&https=true&streamFormat=3"
  3. // key = CryptoJS.enc.Hex.parse("3B4E7F4B13980C603A2936C5C3C304C85B823D8A581AA18A"); // key
  4. // iv = CryptoJS.enc.Hex.parse("8C92E8813637F416");
  5. function encrypted (msg, key, iv) {
  6. return CryptoJS.TripleDES.encrypt(msg, CryptoJS.enc.Hex.parse(key), {
  7. iv: CryptoJS.enc.Hex.parse(iv),
  8. mode: CryptoJS.mode.CBC,
  9. padding: CryptoJS.pad.Pkcs7
  10. }).toString();
  11. }
  12. function getRandomWithLen () {
  13. for (var t = "", i = 0; i < 16; i++) {
  14. var n = 93 * Math.random() + 33 >> 0;
  15. t += String.fromCharCode(n)
  16. }
  17. return t
  18. }
  19. function toHexStr (e) {
  20. for (var t = "", i = 0; i < e.length; i++)
  21. t += e.charCodeAt(i).toString(16);
  22. return t
  23. }
  24. // function getSignatureWithKey(e){
  25. // var t = toHexStr(e);
  26. // console.log(t)
  27. // return stringify(t)
  28. // }
  29. // function stringify(e){
  30. // for (var t = e.words, i = e.sigBytes, n = [], a = 0; a < i; a++) {
  31. // var r = t[a >>> 2] >>> 24 - a % 4 * 8 & 255;
  32. // n.push((r >>> 4).toString(16)),
  33. // n.push((15 & r).toString(16))
  34. // }
  35. // return n.join("")
  36. // }
  37. // function parse(e){
  38. // for (var t = e.length, i = [], n = 0; n < t; n += 2)
  39. // i[n >>> 3] |= parseInt(e.substr(n, 2), 16) << 24 - n % 8 * 4;
  40. // return new s.init(i,t / 2)
  41. // }
  42. function get3rdKeyRandom(){
  43. var t = "mhpptv"
  44. , i = getRandomWithLen()
  45. , n = i;
  46. i += t + "-1V8oo0Or1f047NaiMTxK123LMFuINTNeI";
  47. var a = toHexStr(i);
  48. return {
  49. random_hex: encodeHex(n),
  50. signature_hex: a
  51. }
  52. }
  53. function encodeHex(e) {
  54. for (var t = "", i = e.length, n = 0; n < i; ++n) {
  55. var a = e.charCodeAt(n);
  56. t += "0123456789abcdef"[a >> 4],
  57. t += "0123456789abcdef"[15 & a]
  58. }
  59. return t
  60. }
  61. // const msg = "type=mhpptv&appId=pptv.web.h5&appPlt=web&appVer=1.0.4&channel=sn.cultural&sdkVer=1.5.0&cid=23764751&allowFt=0,1,2,3&rf=0&ppi=302c393939&o=www.google.com&ahl_ver=1&ahl_random=2c6944735c676e643244406266524a7c&ahl_signa=2c6944735c676e643244406266524a7c6d68707074762d3156386f6f304f7231663034374e61694d54784b3132334c4d4675494e544e6549&vvId=1ca862ac-d8eb-4ddd-86a3-daa958004eee&version=1&https=true&streamFormat=3"
  62. // key = "3B4E7F4B13980C603A2936C5C3C304C85B823D8A581AA18A"
  63. // iv = "8C92E8813637F416"
  64. // console.log(encrypted(msg, key, iv).toString())
  65. // console.log(get3rdKeyRandom())