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

📄 test.java

📁 加密解密程序,实现了加密解密功能,无解密密码
💻 JAVA
字号:
import java.io.*;


public class Test
{
	public static void main(String[] args)
	{    
	    System.out.print("Encode follow string: ");
	    String a=MyInput.readString();
        byte[] b=new byte[a.length()];
	    b=a.getBytes();
	    File tempfile=new File("temp.dat");


// encode output		
		try
		{
	        FileOutputStream out=new FileOutputStream(tempfile);
		    EncryptOutputStream Eout=new EncryptOutputStream(out);
		    Eout.ewrite(b);
		    System.out.println("Save successfully!");
 		}
		catch (IOException ex) 
		{
		    System.out.println(ex);
		}
		
	

//non-decode input		

		byte[] read=new byte[a.length()];
		try
		{
			System.out.print("use FileInputStream to open file:  ");
		    int temp;
 	        FileInputStream in=new  FileInputStream(tempfile);
		     temp=in.read(read);
		     String str=new String(read);
		     if(temp!=-1)
		     System.out.println(str);
		     in.close();
		}
		catch (IOException ex) 
		{
			System.out.println(ex);
		}
		

//decode input		
			try
		{   System.out.print("use DecryptInputStream to open file:  ");
		    byte[] nread=new byte[a.length()];
		    int temp;
 	        FileInputStream din=new FileInputStream(tempfile);
         	DecryptInputStream Di=new DecryptInputStream(din);
            temp=Di.dread(nread);
		    String nstr=new String(nread);
		    if(temp!=-1)
		    System.out.println(nstr);
		    din.close();
		}
		
		catch (IOException ex) 
		{
			System.out.println(ex);
		}
		
	}
}

⌨️ 快捷键说明

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