Skip to content

Commit

Permalink
encode-urls with yesterday date
Browse files Browse the repository at this point in the history
  • Loading branch information
recap committed Jun 10, 2024
1 parent a4bc35a commit 701306e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions encode-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ if (!secretKey) {
console.log("[ERROR] no secret key")
return
}
function getYmdDate() {
const now = new Date()
function getYmdDate(now) {
// const now = new Date()
let month = ("0" + (now.getMonth() + 1)).slice(-2)
let day = ("0" + now.getDate()).slice(-2)
return `${now.getFullYear()}${month}${day}`
}
const now = getYmdDate()
const today = getYmdDate(new Date())
const yesterday = getYmdDate(new Date(Date.now() - 86400000))
const date = today
hosts.forEach((host) => {
experimentIds.forEach((experimentId) => {
console.log(`URLS for experiment: ${experimentId}`)
console.log(`URLS for experiment: ${experimentId} with date: ${date}.`)
users.forEach((u) => {
const dataToSign = `${u}:${now}:${experimentId}`
const dataToSign = `${u}:${date}:${experimentId}`
const signatureWordArray = CryptoJS.HmacSHA256(dataToSign, secretKey)
const signatureHex = CryptoJS.enc.Hex.stringify(signatureWordArray)
console.log(
Expand Down

0 comments on commit 701306e

Please sign in to comment.