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

大兴安岭做网站哪个厂家的logo品牌设计

大兴安岭做网站,哪个厂家的logo品牌设计,wordpress配置发信,制作公司网站的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.15wanjia.com/news/185773.html

相关文章:

  • 重庆微信网站北京网络公司都有哪些
  • 如何做适合网站大小的图片郑州网站制作怎么样
  • phpcmsv9网站地图sem是什么检测分析
  • 西宁网站设计公司价格海口企业做网站设计
  • seo推广网站wordpress网站阿里云备案号
  • 网站设计顺德贵阳网站开发多少钱
  • 成都企业网站免费网页在线代理服务
  • 软装设计师seopeixunwang
  • 外贸做网站建设哪家好招聘网站建设保定
  • 直播软件下载网站网站建设与维护实训ppt
  • 手机网站做分享到微信网站的内容更新
  • 虚拟主机建站wordpress更换域名2017
  • 怎么让自己做的网站让别人看到如何做vip微信电影网站
  • 做网站在哪数据展示网站
  • 网站建设推广渠道网站自己的
  • 网站备案核验号织梦网站安装播放视频插件下载
  • 深圳市seo网站设计哪家好淄博做网站的公司都有哪些
  • 自学网站建设工资快速网站建设哪家好
  • 安徽做手机网站免费域名空间申请
  • 阜阳中国建设银行官网站怎么自己做个网站做链接跳转
  • 一级a做爰片免费网站孕交视频dw制作学校官网页面
  • 网站开发需要哪些岗位福州网站建设名列前茅
  • 绍兴建站公司模板一个空间能否做两个网站
  • 个人建个网站多少钱古典 网站模板
  • dns加网站新乡seo网络推广费用
  • 企业做网站的用途网站修改解析怎么做
  • 海外网站推广方案公众号怎么制作文章
  • 福建省城乡和住房建设厅网站做网站常用字体
  • 类似猪八戒的网站建设网站个人备案需要什么
  • uniapp怎么做淘客网站门户网站建设为企业带来的好处