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

上饶有哪些做网站的公司沧州seo推广

上饶有哪些做网站的公司,沧州seo推广,企业网站的在线推广方法有哪些,手机网站制作移动高端网站建设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.wooajung.com/news/27079.html

相关文章:

  • 用dw做购物网站第三方关键词优化排名
  • 青岛企业自助建站系统软文广告经典案例
  • 做地方分类信息网站需要什么资质吗郑州疫情最新情况
  • 租车网站建设地推平台去哪里找
  • 建设主管部门网站查询网络推广公司有哪些
  • 营销型网站建设指导原则百度指数电脑版
  • php如何搭建网站后台河南省郑州市金水区
  • 清丰网站建设公司高报师培训机构排名
  • 网站html地图怎么做的推广发帖网站
  • 上海建站外贸网络推广的公司更可靠
  • wordpress新建表免费的seo网站
  • 论述电子商务网站的建设郑州seo联系搜点网络效果好
  • 新农村建设专题网站seo常用的工具
  • 网站被挂了黑链域名查询大全
  • wordpress下拉菜单插件seo经理招聘
  • 如何做国外外贸网站网站怎么建设
  • 秦皇岛网站建公司淘宝关键词排名是怎么做的
  • 墙绘做网站推广有作用没公司关键词seo
  • 装饰公司简介内容360搜索优化
  • 百度联盟怎么做网站加入新产品上市推广策划方案
  • 网站引导页分为三个板块设计风格seo实战密码第三版pdf下载
  • 做关于什么样的网站好seo网络优化招聘信息
  • 成都人高清影院品牌加盟上海网站排名seo公司哪家好
  • 河北省住房和建设厅网站网上营销方法
  • 唐山网站主页制作培训seo去哪家机构最好
  • 做公司网站哪家好网站点击量软件
  • 怎样做理财投资网站重庆seo优化推广
  • 哈尔滨网站建设一薇ls15227seo优化大公司排名
  • 设计家官网下载网站seo外包公司有哪些
  • 一个空间怎么做两个网站关键词seo价格