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

📄 yuyanshan.java

📁 混顿加密算法
💻 JAVA
字号:


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Yuyanshan {
	
	static double A = 4.0;
	static double B = 2.5;
	public static double x1 = 3.134;
	static int x = 1;
	static double x11 = x1;

	public static byte toyihuo() {
		byte byteNum = 0;
		double x2;
		for(int i=0;i<8;i++) {
			byteNum = (byte)(byteNum << 1);
			
			x2 = A * Math.sin(x1 - B) * Math.sin(x1 - B);
			if(x2 >= 2 * A / 3){
				byteNum = (byte)(byteNum | 1);
			}
			x1 = x2;
			
		}
		
		return byteNum;
	}
	
	public static byte toyihuo1() {
		byte byteNum = 0;
		double x2;
		for(int i=0;i<8;i++) {
			byteNum = (byte)(byteNum << 1);		
			x2 = A * Math.sin(x11 - B) * Math.sin(x11 - B);
			if(x2 >= 2 * A / 3){
				byteNum = (byte)(byteNum | 1);
			}
			x11 = x2;
			
		}
		return byteNum;
	}
	
	public static void encodeImage() {
		FileInputStream in = null;
		FileOutputStream out = null;
		byte[] b1 = null;
		byte[] b2 = null;
		//byte[] mybyte = null;
			try {
				in = new FileInputStream("D:/tiger.bmp");
				b1 = new byte[54];
				b2 = new byte[in.available()-54];
				in.read(b1);
				in.read(b2);
				for(int i=55;i<b2.length;i++) {
					b2[i] = (byte)(b2[i]^Yuyanshan.toyihuo());
				}
				out = new FileOutputStream(new File("D:/yuyanshanEncode.bmp"));
				out.write(b1);
				out.write(b2);	
				System.out.println("yuyanshan 200408202118 encode done !");
			} catch (FileNotFoundException e) {
				System.out.println("file not found !");
			} catch (IOException e) {
				e.printStackTrace();
			}
		
	}
	
	public static void decodeImage() {
		FileInputStream in = null;
		FileOutputStream out = null;
		byte[] b1 = null;
		byte[] b2 = null;
			try {
				in = new FileInputStream("D:/yuyanshanEncode.bmp");
				b1 = new byte[54];
				b2 = new byte[in.available()-54];
				in.read(b1);
				in.read(b2);
				for(int i=55;i<b2.length;i++) {
					b2[i] = (byte)(b2[i]^Yuyanshan.toyihuo1());
				}
				out = new FileOutputStream(new File("D:/yuyanshanDecode.bmp"));
				out.write(b1);
				out.write(b2);			
				System.out.println("yuyanshan 200408202118 decode done !");
			} catch (FileNotFoundException e) {
				System.out.println("file not found !");
			} catch (IOException e) {
				e.printStackTrace();
			}
	}
	public static void main(String[] args) {
		Yuyanshan.encodeImage();
		Yuyanshan.decodeImage();
	}

}

⌨️ 快捷键说明

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