⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jaes.java

📁 自己实现的AES和DES的加密算法。自己可以随意组成加密数据结构
💻 JAVA
字号:
package com.cmcc.common.util;

import com.cmcc.bean.EncryptedDataV2;

public class JAES {
	// private static byte[] iv = new byte[] { 85, 60, 12, 116, 99, -67, -83,
	// 19,
	// -118, -73, -24, -8, 82, -24, -56, -14 };

	public static byte[] decrypt(byte[] sSrc, String sKey) throws Exception {
		byte[] iv = new byte[] { 85, 60, 12, 116, 99, -67, -83, 19, -118, -73,
				-24, -8, 82, -24, -56, -14 };
		AesJni aj = new AesJni();
		byte[] ret_decrypt = aj.decode_aes(sKey, iv, sSrc, sSrc.length);
		iv = null;
		return ret_decrypt;
	}

	public static byte[] encrypt(byte[] sSrc, String sKey) throws Exception {
		byte[] iv = new byte[] { 85, 60, 12, 116, 99, -67, -83, 19, -118, -73,
				-24, -8, 82, -24, -56, -14 };
		AesJni aj = new AesJni();
		byte[] ret_encrypt = aj.encode_aes(sKey, iv, sSrc, sSrc.length);
		iv = null;
		return ret_encrypt;
	}

	public EncryptedDataV2 byte2date(byte buff[]) {
		EncryptedDataV2 encryptedDataV2 = new EncryptedDataV2();
		encryptedDataV2.setNonce(ByteOprs.getint(ByteOprs.subBuff(buff, 0, 4),
				0));
		encryptedDataV2.setCreateTime(ByteOprs.getlong(ByteOprs.subBuff(buff,
				4, 8), 0));
		encryptedDataV2.setExpireTime(ByteOprs.getlong(ByteOprs.subBuff(buff,
				12, 8), 0));
		encryptedDataV2.setUserTypeV2(ByteOprs.subBuff(buff, 20, 1)[0]);
		encryptedDataV2.setMobile(ByteOprs.getlong(ByteOprs
				.subBuff(buff, 21, 8), 0));
		encryptedDataV2.setSid(ByteOprs
				.getint(ByteOprs.subBuff(buff, 29, 4), 0));
		encryptedDataV2.setLogicalPoolId(ByteOprs.getshort(ByteOprs.subBuff(
				buff, 33, 2), 0));
		encryptedDataV2.setUserStatusV2(ByteOprs.getint(ByteOprs.subBuff(buff,
				35, 4), 0));
		encryptedDataV2.setUserIp(ByteOprs.getlong(ByteOprs
				.subBuff(buff, 39, 8), 0));
		return encryptedDataV2;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -