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

📄 encryptedbytev2.java

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

import com.cmcc.common.util.ByteOprs;
import com.cmcc.common.util.SHA1;

/**
 * @author zhanglm E-mail:zhanglm@hdxt.net.cn
 * @version 创建时间:2008-7-21 下午09:00:33 类说明
 */
public class EncryptedByteV2 {
	private byte nonce[];
	private byte createTime[];
	private byte expireTime[];
	private byte userTypeV2[];
	private byte mobile[];
	private byte sid[];
	private byte logicalPoolId[];
	private byte userStatusV2[];
	private byte userIp[];
	private byte eid[];
	private byte hash[];
	private byte buff[];

	public EncryptedByteV2() {
		this.setNonce((int) (1 + Math.random() * (10 - 1 + 1)));
	}

	private byte[] getEid() {
		return eid;
	}

	public void setEid(long eid) {
		this.eid = ByteOprs.long2byte(eid);
	}
	
	private byte[] getNonce() {
		return nonce;
	}

	public void setNonce(int nonce) {
		this.nonce = ByteOprs.int2byte(nonce);
	}

	public byte[] getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = ByteOprs.long2byte(createTime);
	}

	public byte[] getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(long expireTime) {
		this.expireTime = ByteOprs.long2byte(expireTime);
	}

	public byte[] getUserTypeV2() {
		return userTypeV2;
	}

	public void setUserTypeV2(byte userTypeV2) {
		byte dest[] = new byte[1];
		dest[0] = userTypeV2;
		this.userTypeV2 = dest;
	}

	public byte[] getMobile() {
		return mobile;
	}

	public void setMobile(long mobile) {
		this.mobile = ByteOprs.long2byte(mobile);
	}

	public byte[] getSid() {
		return sid;
	}

	public void setSid(int sid) {
		this.sid = ByteOprs.int2byte(sid);
	}

	public byte[] getLogicalPoolId() {
		return logicalPoolId;
	}

	public void setLogicalPoolId(short logicalPoolId) {
		this.logicalPoolId = ByteOprs.short2byte(logicalPoolId);
	}

	public byte[] getUserStatusV2() {
		return userStatusV2;
	}

	public void setUserStatusV2(int userStatusV2) {
		this.userStatusV2 = ByteOprs.int2byte(userStatusV2);
	}

	public byte[] getUserIp() {

		return userIp;
	}

	public void setUserIp(long userIp) {
		this.userIp = ByteOprs.long2byte(userIp);
	}

	public byte[] getHash() {
		byte temp1[] = ByteOprs.addBuff(this.getNonce(), this.getCreateTime());
		byte temp2[] = ByteOprs.addBuff(temp1, this.getExpireTime());
		byte temp3[] = ByteOprs.addBuff(temp2, this.getUserTypeV2());
		byte temp4[] = ByteOprs.addBuff(temp3, this.getMobile());
		byte temp5[] = ByteOprs.addBuff(temp4, this.getSid());
		byte temp6[] = ByteOprs.addBuff(temp5, this.getLogicalPoolId());
		byte temp7[] = ByteOprs.addBuff(temp6, this.getUserStatusV2());
		byte temp8[] = ByteOprs.addBuff(temp7, this.getUserIp());
		this.buff = ByteOprs.addBuff(temp8, this.getEid());
		// this.buff =
		// addBuff(addBuff(addBuff(addBuff(addBuff(addBuff(addBuff(addBuff(this.getNonce(),
		// this
		// .getCreateTime()), this.getExpireTime()), this.getUserTypeV2()),
		// this.getMobile()), this.getSid()),
		// this.getLogicalPoolId()), this.getUserStatusV2()), this.getUserIp());
		SHA1 sha1 = new SHA1();
		this.hash = sha1.getDigestOfBytes(this.buff);
		return this.hash;
	}

	public byte[] getByteV2() {
		byte temp[] = this.getHash();
		return ByteOprs.addBuff(this.buff, temp);
	}

	private String getRandomNumber() {
		String password = "";

		for (int i = 0; i < 6; i++) {
			password += new Character((char) (48 + 10 * Math.random()))
					.toString();
		}
		return password;
	}
}

⌨️ 快捷键说明

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