decrypt.middleware.ts
530 Bytes
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
const CryptoJS = require('crypto-js');
@Injectable()
export class DescryptMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
// req.body = (CryptoJS.AES.decrypt(req.body.data, 'ditohash').toString(CryptoJS.enc.Utf8));
console.log(
CryptoJS.AES.decrypt(req.body.data, 'ditohash').toString(
CryptoJS.enc.Utf8,
),
);
next();
}
}