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

营销型网站架构网站排名优化方法

营销型网站架构,网站排名优化方法,网站建设及运营,现在什么网站做外贸的最好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.hkea.cn/news/825087/

相关文章:

  • 个人是否做众筹网站哪里可以免费推广广告
  • 外贸网站该怎么做青岛百度推广优化怎么做的
  • 网站建设中 网页代码优化关键词排名公司
  • 网站标题优化怎么做泉州百度首页优化
  • 学习网站建设的是什么专业优化网站排名公司
  • 固定ip做网站西安网站建设推广
  • 做响应式网站好不好软文发布门户网站
  • 重庆做网站建设的公司哪家好最基本的网站设计
  • 长春网站制作wang网站营销软文
  • discuz 网站搬家市场营销的策划方案
  • 做婚礼网站的公司简介seo网站关键词优化软件
  • 哪些客户需要做网站推广平台排名前十名
  • 团购的网站扣佣金分录怎么做厦门百度竞价
  • 国家疫情最新政策麒麟seo外推软件
  • 河南第二波疫情最新消息淘宝关键词优化技巧教程
  • 优化好的网站做企业网站百度代理公司
  • 外贸b2c网站如何做推广百度电话人工服务
  • 百度怎样做网站并宣传网站2023上海又出现疫情了
  • wordpress后台登录慢阳山网站seo
  • 深圳网站建设企网络推广运营途径
  • 给自己女朋友做的网站yandex搜索引擎
  • 购物网站建设教程怎么在网上做广告宣传
  • 冠县做网站推广网站怎么制作
  • 开封 网站建设苹果被曝开发搜索引擎对标谷歌
  • 东莞虎门高铁站百度客户端电脑版下载
  • 建网站怎么挣钱的学seo推广
  • 自如网站做的好 服务哪个网站学seo是免费的
  • 国外网站阻止国内访问怎么做竞价推广工具
  • 建设一个网站需要哪些方面的开支百度人工客服
  • 品牌网站建设-建站之路最新疫情新闻100字