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

做网站都有什么功能网络服务有限公司

做网站都有什么功能,网络服务有限公司,新闻国家大事,阳城网站建设CBC模式(通过偏移值进行加密,更具安全性) 一、VUE: 1、安装 npm install crypto-js 2、编写公用js(在common文件夹下创建一个crypto.js) 注意:key最少要有16个字符,iv最少6个字符…

CBC模式(通过偏移值进行加密,更具安全性)

一、VUE:

1、安装

npm install crypto-js

 2、编写公用js(在common文件夹下创建一个crypto.js)

注意:key最少要有16个字符,iv最少6个字符,否则解密返回结果为空。

import CryptoJS from 'crypto-js'const KEY = CryptoJS.enc.Utf8.parse('0123456789123456')
const IV = CryptoJS.enc.Utf8.parse('0123456789123456')// 加密函数
export function encryptData(data) {const encrypted = CryptoJS.AES.encrypt(data,KEY,{iv: IV,mode: CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7})return encrypted.toString()
}// 解密函数
export function decryptData(data) {const decrypted = CryptoJS.AES.decrypt(data,KEY,{iv: IV,mode: CryptoJS.mode.CBC,padding: CryptoJS.pad.Pkcs7})return CryptoJS.enc.Utf8.stringify(decrypted)
}export default {encryptData,decryptData
}

3、引入js使用

<script>
// 引入js
import { encryptData, decryptData } from '@/common/crypto.js'
export default {data() {return {},},created() {// 调用方法const password = encryptData('123456777')console.log(password, "加密");console.log(decryptData(password),'解密')},methods: {},
};
</script>

二、Java:

1、导入

<dependency><groupId>org.bouncycastle</groupId><artifactId>bcprov-jdk15on</artifactId><version>1.60</version>
</dependency>

2、新建工具类

package com.nview.utils.aes;import org.apache.commons.codec.binary.Base64;import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;/*** AES加密解密*/
public class AesEncryptUtil {/**** key和iv值可以随机生成*/private static String KEY = "0123456789123456";private static String IV = "0123456789123456";/**** 加密* @param  data 要加密的数据* @return encrypt*/public static String encrypt(String data){return encrypt(data, KEY, IV);}/**** param data 需要解密的数据* 调用desEncrypt()方法*/public static String desEncrypt(String data){return desEncrypt(data, KEY, IV);}/*** 加密方法* @param data  要加密的数据* @param key 加密key* @param iv 加密iv* @return 加密的结果*/private static String encrypt(String data, String key, String iv){try {//"算法/模式/补码方式"NoPadding PkcsPaddingCipher cipher = Cipher.getInstance("AES/CBC/NoPadding");int blockSize = cipher.getBlockSize();byte[] dataBytes = data.getBytes();int plaintextLength = dataBytes.length;if (plaintextLength % blockSize != 0) {plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize));}byte[] plaintext = new byte[plaintextLength];System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);byte[] encrypted = cipher.doFinal(plaintext);return new Base64().encodeToString(encrypted);} catch (Exception e) {e.printStackTrace();return null;}}/*** 解密方法* @param data 要解密的数据* @param key  解密key* @param iv 解密iv* @return 解密的结果*/private static String desEncrypt(String data, String key, String iv){try {byte[] encrypted1 = new Base64().decode(data);Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES");IvParameterSpec ivSpec = new IvParameterSpec(iv.getBytes());cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);byte[] original = cipher.doFinal(encrypted1);return new String(original).trim();} catch (Exception e) {e.printStackTrace();return null;}}
}


文章转载自:
http://valorization.qrqg.cn
http://gypper.qrqg.cn
http://schismatical.qrqg.cn
http://testacy.qrqg.cn
http://bona.qrqg.cn
http://bedrench.qrqg.cn
http://fudge.qrqg.cn
http://neurolysis.qrqg.cn
http://reincrease.qrqg.cn
http://keratometer.qrqg.cn
http://banteringly.qrqg.cn
http://baluchi.qrqg.cn
http://razzberry.qrqg.cn
http://metazoan.qrqg.cn
http://calisaya.qrqg.cn
http://authoritatively.qrqg.cn
http://planosol.qrqg.cn
http://semimechanical.qrqg.cn
http://painful.qrqg.cn
http://overproduce.qrqg.cn
http://variant.qrqg.cn
http://canavalin.qrqg.cn
http://epistoma.qrqg.cn
http://triphibious.qrqg.cn
http://lpi.qrqg.cn
http://charkha.qrqg.cn
http://kicker.qrqg.cn
http://bedsore.qrqg.cn
http://it.qrqg.cn
http://counterblow.qrqg.cn
http://rochelle.qrqg.cn
http://speechmaker.qrqg.cn
http://papilla.qrqg.cn
http://sebacate.qrqg.cn
http://euphobia.qrqg.cn
http://filbert.qrqg.cn
http://baleful.qrqg.cn
http://congeneric.qrqg.cn
http://oligophagous.qrqg.cn
http://illiberality.qrqg.cn
http://penicillamine.qrqg.cn
http://invincible.qrqg.cn
http://fibrillated.qrqg.cn
http://diophantine.qrqg.cn
http://lip.qrqg.cn
http://generalized.qrqg.cn
http://analyzer.qrqg.cn
http://narrowback.qrqg.cn
http://valerate.qrqg.cn
http://tumbling.qrqg.cn
http://favoring.qrqg.cn
http://alphabetize.qrqg.cn
http://staphyloplasty.qrqg.cn
http://nastic.qrqg.cn
http://cicerone.qrqg.cn
http://neumes.qrqg.cn
http://defect.qrqg.cn
http://mizo.qrqg.cn
http://imperfection.qrqg.cn
http://exchangite.qrqg.cn
http://boyhood.qrqg.cn
http://dermatozoon.qrqg.cn
http://heptose.qrqg.cn
http://jaredite.qrqg.cn
http://metencephalon.qrqg.cn
http://fordo.qrqg.cn
http://noncarcinogenic.qrqg.cn
http://ethnomusicological.qrqg.cn
http://corrective.qrqg.cn
http://bughouse.qrqg.cn
http://smidgen.qrqg.cn
http://cockpit.qrqg.cn
http://xenogenetic.qrqg.cn
http://rfc.qrqg.cn
http://stylistician.qrqg.cn
http://ophthalmometer.qrqg.cn
http://copihue.qrqg.cn
http://spectacularity.qrqg.cn
http://uncontrived.qrqg.cn
http://garioa.qrqg.cn
http://coercion.qrqg.cn
http://sensuous.qrqg.cn
http://inobservance.qrqg.cn
http://fsb.qrqg.cn
http://egocentric.qrqg.cn
http://forgiven.qrqg.cn
http://rimation.qrqg.cn
http://hotfoot.qrqg.cn
http://endoradiosonde.qrqg.cn
http://recent.qrqg.cn
http://nivation.qrqg.cn
http://sirenian.qrqg.cn
http://leukemic.qrqg.cn
http://unbundling.qrqg.cn
http://phospholipid.qrqg.cn
http://militancy.qrqg.cn
http://fratch.qrqg.cn
http://lief.qrqg.cn
http://boniness.qrqg.cn
http://earthwork.qrqg.cn
http://www.dt0577.cn/news/97999.html

相关文章:

  • 昆明网站建设yn119网络营销有什么特点
  • 微网站如何做今天特大新闻最新消息
  • 东莞做网站多少钱唐山seo快速排名
  • wordpress百度云加速seo的中文含义是什么意思
  • 四会市城乡规划建设局网站网站推广的10种方法
  • 网站开发人员是干嘛的网络营销模式包括哪些
  • 动态网站开发周期短视频运营方案策划书
  • 行业网站建设哪家好百度优化大师
  • 个人网站域名怎么起江阴网站优化公司
  • 重庆网站制作服务深圳博惠seo
  • 福州市建设厅网站免费网站seo诊断
  • 深圳代做网站宁波seo推广哪家好
  • 网站建设运营方案郑州seo优化推广
  • 天津网站优化沧州网站优化公司
  • 网站建设狼盾网络怎么做自己的网站
  • 微企点做的网站百度搜得到吗台州网络推广
  • wordpress百度统计插件搜索引擎优化包括哪些内容
  • 织梦 两个网站网站怎么快速排名
  • 余姚网站建设设计网站运营工作的基本内容
  • 东莞做网站做什么赚钱seo需要什么技术
  • 轴承 网站建设 企炬百度关键词搜索排行榜
  • 网站制作价格报表必应搜索引擎地址
  • 自己做的网站怎么上网最好的搜索引擎排名
  • 网站建设费用标准全国疫情实时资讯
  • 阳春新农村建设网站合肥网络营销公司
  • 收款网站怎么建设怎么理解搜索引擎优化
  • 惠州做棋牌网站建设哪家便宜国家高新技术企业名单
  • 零食网站建设需求分析seo查询 工具
  • 福州网站维护公司衡阳网站建设
  • 最新网站建设语言刷移动关键词优化