self_example/Spider/Chapter11_JavaScript逆向/Node执行js/main_web.js

26 lines
783 B
JavaScript

const CryptoJS = require("./crypto")
const express = require("express")
const app = express();
const port = 3000;
app.use(express.json());
function getToken(player) {
let key = CryptoJS.enc.Utf8.parse("fipFfVsZsTda94hJNKJfLoaqyqMZFFimwLt")
const {name, birthday, height, weight} = player
let base64Name = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(name))
let encrypted = CryptoJS.DES.encrypt(`${base64Name}${birthday}${height}${weight}`, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return encrypted.toString()
}
app.post("/", (req, res) => {
const data = req.body;
console.log(data)
res.send(getToken(data));
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}!`)
})