Files
huike-front/tests/unit/upyun.spec.ts
T
weli a661e439a0 chore: initialize frontend repo with teaching terminology updates
Add the current frontend codebase with a baseline .gitignore and update piano-specific UI terms to teaching-oriented terms for the current product context.

Made-with: Cursor
2026-04-23 16:37:14 +08:00

16 lines
646 B
TypeScript

import Crypto from 'crypto-js';
describe('upyun access token', () => {
test('calculate access token', () => {
const secret = "C29DBA1F1EA4462088136C3A85C2FBFC";
// const etime = Math.ceil(Date.now() / 1000) + 3600; // 1小时有效
let etime = 1657886416;
const uri = '/music-room/17c832cb-bc6b-41f7-96cd-190b7fe4a3d7.jpeg';
const sign = Crypto.MD5(`${secret}&${etime}&${uri}`).toString();
let upt = sign.substring(12, 12 + 8) + etime;
console.log(sign, upt, etime)
expect(sign).toBe('48d172b8b96b84f91d806a7beee421f1')
expect(upt).toBe('84f91d801657886416')
})
})