当前位置: 首页 > news >正文

网站优化主要怎么做亚马逊开店流程及费用

网站优化主要怎么做,亚马逊开店流程及费用,web优秀网站h5案例分享,南通网站制作deriveKey 方法的完整示例,演示如何使用 HMAC 作为密钥派生函数(KDF)来从一个给定的秘密(如密码)派生出一个新的 AES 加密密钥。 //创建一个函数来生成随机盐function getRandomSalt(length){let arraynew Uint8Array…

deriveKey 方法的完整示例,演示如何使用 HMAC 作为密钥派生函数(KDF)来从一个给定的秘密(如密码)派生出一个新的 AES 加密密钥。

//创建一个函数来生成随机盐function getRandomSalt(length){let array=new Uint8Array(length);window.crypto.getRandomValues(array);return array;}//生成随机数字function randomFloat(){const fooArray=new Uint32Array(1);const maxUint32=0xFFFFFFFF;return crypto.getRandomValues(fooArray)[0];}//生成随机密码,导入密钥当中function getKeyMaterial(){//const password=window.prompt("请输入你的密码");//就是为加密时用密码//这里不用输入密码,我们采用随机生成的数字,这样可以增加破解难度,提升安全性const password=randomFloat();const enc=new TextEncoder();return window.crypto.subtle.importKey("raw",enc.encode(password),"PBKDF2",false,["deriveBits","deriveKey"]);}
//创建一个函数来派生密钥async function deriveAeskey(salt,info,keyLength){//生成已有密钥//不能直接用new Textcoder().encoder(password)这样来生成密码,必须用这个函数的importKey导入密钥才行const passwordBuffer=await getKeyMaterial();const derivedKey=await crypto.subtle.deriveKey({name:'PBKDF2',salt:salt,iterations:10000,hash:'SHA-256'},passwordBuffer,{name:'AES-GCM',length:keyLength},true,["encrypt","decrypt"]);return derivedKey;}//使用派生的密钥进行加密async function encryptData(derivedKey,dataToEncrypt){const encoder=new TextEncoder();const dataBuffer=encoder.encode(dataToEncrypt);const iv=window.crypto.getRandomValues(new Uint8Array(12));const encryption=await crypto.subtle.encrypt({name:'AES-GCM',iv:iv},derivedKey,dataBuffer);return {ciphertext:encryption,iv:Array.from(iv)}}//使用派生的密钥进行解密async function decryptData(derivedKey,ciphertext,iv){const decrypted=await crypto.subtle.decrypt({name:'AES-GCM',iv:new Uint8Array(iv)},derivedKey,ciphertext);const decoder=new TextDecoder();return decoder.decode(decrypted);}//最后把他们综合到一起,进行加密和解密,以及做加密后内容的演式(async function(){const salt=getRandomSalt(16);const info=new Uint8Array();const keyLength=256;try{//派生的密钥const derivedKey=await deriveAeskey(salt,info,keyLength);//需要加密的数据const dataToEncrypt="this is data";const {ciphertext,iv}=await encryptData(derivedKey,dataToEncrypt);//这里是演式你加密后的数据样式console.log(String.fromCharCode(...new Uint8Array(ciphertext)));//解密数据const decryptedData=await decryptData(derivedKey,ciphertext,iv);console.log('解密数据:',decryptedData);}catch(error){console.log('加解密时发生错误',error);}})();
http://www.dt0577.cn/news/38098.html

相关文章:

  • 时时彩网站怎么建设百度免费下载安装
  • seo网站优化方案书下载班级优化大师app
  • wordpress批量删除字段关键词优化推广公司排名
  • 在线培训网站seo公司广州
  • 做301到别人网站搜索引擎营销的五大特点
  • 网站界面设计规则百度seo排名在线点击器
  • 网站在浏览器的图标怎么做地推接单网
  • 如何做一款服装网站广州seo公司推荐
  • 移动端网站建设全国各大新闻网站投稿
  • 开淘宝的店铺网站怎么做深圳seo论坛
  • 重庆网络公司排行榜谷歌seo综合查询
  • 精美网站制作重庆百度搜索优化
  • 做基本的网站2345网址大全设主页
  • 时尚网站欣赏代写
  • ui最好的网站网络推广的概念
  • 深圳企业营销型网站烟台seo外包
  • 建设部网站合并百度热度指数排行
  • 中国建设银行校园招聘网站织梦seo排名优化教程
  • 服务器怎么做网站教程91永久免费海外地域网名
  • asp.net做网站seo关键词优化推广
  • 自助建站网站源码希爱力双效片骗局
  • 洛阳住房和城乡建设部网站百度做网站需要多少钱
  • 做信誉认证对网站有什么好处在什么网站可以免费
  • 奉化网站建设抖音账号权重查询
  • 以人为本网站建设空间出租推广
  • 做网站建设业务百度网站推广电话
  • 无锡网站App微信刷链接浏览量网站
  • 网站框架类型网络竞价推广托管公司
  • 小区网站建设如何进入网站
  • 外贸自己做网站外链互换平台