javascript - CryptoJS 的 crypto.createCipheriv 等价物是什么?
问题描述
我想为 Redsys 制作一个签名令牌,但我发现的所有加密方法都在 javascript native、java 或 php 中。
我为 NodeJs 找到了这个Redsys Api,但加密不兼容。所以我尝试切换到 CryptoJS,但该createCipheriv
功能不适用于 CryptoJs。
我想做的事...
signature( key ){
var thisObj = this;
function getOrderId(){
var ret;
thisObj.params.forEach(function(item, key){
if (key.toUpperCase() === 'DS_MERCHANT_ORDER'){
ret = item;
return -1; }
})
return ret;
}
var iv = Buffer.alloc( 8, 0, 'utf8' );
var cipher = CryptoJS.createCipheriv('des-ede3-cbc', Buffer.from( key , 'base64'), iv);
cipher.setAutoPadding(false);
var orderId = Buffer.from(getOrderId());
var pad = Buffer.alloc((Math.ceil(orderId.length / 8) * 8) - orderId.length, 0);
key = Buffer.concat([cipher.update(orderId), cipher.update(pad), cipher.final()]);
var hash = CryptoJS.createHmac( 'sha256', key );
hash.update(Buffer.from(this.createMerchantParameters()));
return hash.digest('base64');
}
/// ERROR Error: Uncaught (in promise): TypeError: crypto_js__WEBPACK_IMPORTED_MODULE_3__.createCipheriv is not a function
CryptoJS 的 crypto.createCipheriv 等价物是什么?
解决方案
推荐阅读
- android - Android Studio 4.2.2 - 安装的构建工具版本 31.0.0 已损坏。使用 SDK 管理器删除并重新安装
- math - 情感分析中支持向量机背后的数学
- r - 按组删除重复的年份行
- azure-storage - Azure 存储资源管理器 - 筛选上次修改时间
- wagtail - 页面类型随机显示“主页”或“页面”
- php - Codeigniter - 帐户在一段时间后注销
- telegram-bot - python-telegram-bot 中的 TimedOut 但已发送消息
- c# - asp.net MVC 上传文件名为 System.Web.HttpPostedFileWrapper
- flutter - 未定义的类“位置数据”。尝试将名称更改为现有类的名称,或创建一个名为“LocationData”的类
- service - 我可以在同一个 ECS fargate 集群上同时运行多个服务吗