node.js - 表格中发送后看到的数据,会是什么?
问题描述
数据是在表单中发送后看到的,可能是我使用angular作为前端,nodejs作为后端,非常感谢支持,需要注意的是我是angular初学者
<div class="container p-5">
<div class="row">
<div class="col-md-4 mx-auto">
<div class="card">
<div class="card-header">
Acceso al Sistema
</div>
<div class="card-body">
<form (submit)="login()" >
<div class="form-group">
<input type="text" [(ngModel)]="user.email" name="email" class="form-control" placeholder="Email" autofocus>
</div>
<div class="form-group">
<input type="password" [(ngModel)]="user.contrasenia" name="password" class="form-control" placeholder="Contraseña" >
</div>
<button type="submit" class="btn btn-primary btn-block">
Ingresar
</button>
</form>
</div>
</div>
</div>
</div>
</div>
export class Usuarios {
constructor(email=''){
this.email = email
}
_id:string;
nombre_completo: string;
apellido_paterno:string;
apellido_materno:string;
roles:string;
email:string;
contrasenia:string;
}
解决方案
您可以加密数据并发送到服务器,在服务器端您可以解密数据请在下面找到示例代码
import * as CryptoJS from 'crypto-js';
decryptParams(result, password) {
// console.log('to decrypt' + result);
let decryptedString: any;
const words = CryptoJS.enc.Base64.parse(result);
// console.log('to decrypt' + words);
const textString = CryptoJS.enc.Utf8.stringify(words);
decryptedString = CryptoJS.AES.decrypt(textString, password);
decryptedString = this.hex2a(decryptedString);
return JSON.parse(decryptedString);
}
encryptParams(params, password) {
let encryptedParams: any;
encryptedParams = CryptoJS.AES.encrypt(JSON.stringify(params), password);
encryptedParams = CryptoJS.enc.Utf8.parse(encryptedParams);
encryptedParams = CryptoJS.enc.Base64.stringify(encryptedParams);
// console.log('encry' + encryptedParams);
return encryptedParams;
}
hex2a(hexx) {
const hex = hexx.toString(); // force conversion
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
推荐阅读
- javascript - Javascript计算2个状态
- amazon-web-services - AWS Fargate 上的 Strapi 部署(无服务器)-Aurora MySQL(无服务器)
- laravel - 在 osiset app shopify 中实施定期订阅
- python - 如何使用 PHP 将有效负载卷曲到 python api?
- javascript - VueJS - 使用 vue 提供创建全局服务功能,在 vue 组件中调用服务时未定义
- vue.js - 如何在Vue中进行求和
- javascript - 无法将时间戳转换为格式化日期
- react-native - 编辑时如何在文件上传中获取文档
- reactjs - 如何修复“Array.prototype.filter() 期望在箭头函数结束时返回一个值”
- excel - 基于列值复制行的循环