栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

des统计信息代码

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

des统计信息代码

这是des报告的代码,一共2个java文件,复制粘贴就可以啦~

//BitsArray.java
package my_src;
import java.io.*;
import java.util.Random;
public class BitsArray {
	
//	public BitsArray(String bits) {
//		super();
//		this.bits = new byte[64];
//	}
//	public static String RandomBits() {
//		String s="";
//		Random random=new Random();
//		int c=random.nextInt();
//		int d=random.nextInt();
//		s+=Integer.toBinaryString(c)+Integer.toBinaryString(d);
//		int total=64-s.length();
//		for(int i=0;i'0'?'0':'1';
		}
		String s="";
		for(int i=0;i 
//des_statics.java
package my_src;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

import static my_src.BitsArray.*;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
public class des_statistic {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Cipher des = null;
		
		// 存放 密钥
		byte[] des_key = new byte[8];
		
		// 存放 明文
		byte[] des_input = new byte[8];
		
		// 存放 加密后的输出
		byte[] des_output = null;
		
		for(int i=0; i < 8; i++)
		{
			des_key[i] = 0x11;
			des_input[i] = 0x11;
		}
		
		SecretKey secretKey = new SecretKeySpec(des_key, "DES");
		
		// 创建des 密码算法对象,指定电码本模式和无填充方式
		try {
			des = Cipher.getInstance("DES/ECB/NoPadding");
		} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		// 初始化 des 算法
		try {
			des.init(Cipher.ENCRYPT_MODE, secretKey);
		} catch (InvalidKeyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		// 加密
		try {
			des_output = des.doFinal(des_input);
		} catch (IllegalBlockSizeException | BadPaddingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		changeInput(des_key, des_input, des_output);
		changeCipher(des_key, des_input, des_output);
	}
	
	public static void changeCipher(byte[] des_key,byte[] des_input,byte[] des_output){
		Cipher des=null;
		SecretKey secretKey=null;
		int randtimes=10;
		int deffOnOut=0;
		byte[] randDes_output=null;
		String des_keyString=bitsToString(des_key);
		String des_outputString=bitsToString(des_output);
		String randDes_keyString="";
		String randDes_outputString="";
		byte[] randDes_key=null;
		// 创建des 密码算法对象,指定电码本模式和无填充方式
		try {
			des = Cipher.getInstance("DES/ECB/NoPadding");
		} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
			e.printStackTrace();
		}
		for(int i=1;i<=64;i++) {
			for(int j=0;j
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/328704.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号