| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Pretend Station Request
- import { AESCipher } from '../src/utils/cipher/aes'
- import { HmacCipher } from '../src/utils/cipher/hmac'
- import { ChargeStationReqEndPointDTO } from '../factory-types/src/dto/chargeStation/endPoint/end.dto'
- const aesCipher = new AESCipher()
- const hmacCipher = new HmacCipher()
- const secret = {
- Crazy_Charge_DataSecret: '1ebbf89ffaaff9c6',
- Crazy_Charge_DataSecretIV: '8fd9154b6ef6f7c1',
- Crazy_Charge_SigSecret: 'a955047992ff5096',
- }
- const data = {
- ConnectorID: 'string',
- Status: 0,
- ParkStatus: 1,
- LockStatus: 1,
- }
- const encryptData = aesCipher.encrypt(
- JSON.stringify(data),
- // 'abc',
- // 'def'
- secret.Crazy_Charge_DataSecret,
- secret.Crazy_Charge_DataSecretIV
- )
- const payload: ChargeStationReqEndPointDTO = {
- OperatorID: '192316877',
- Data: encryptData,
- Seq: '0001',
- TimeStamp: '20240628075810',
- }
- const constructSigText =
- payload.OperatorID + payload.Data + payload.TimeStamp + payload.Seq
- payload.Sig = hmacCipher.hmacMD5Sign(
- constructSigText,
- secret.Crazy_Charge_SigSecret
- )
- console.log(JSON.stringify(payload))
|