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

📄 privateexample.java

📁 非常有用的加密解密程序
💻 JAVA
字号:
package ss.logic;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import java.security.Key;

public class PrivateExample{
	
	public static void main(String[] args) throws Exception{
	
		String plainTextStr = "ABCEETR$%#?><E#2213";
		byte[] plainText = plainTextStr.getBytes("UTF8");
		System.out.println(plainTextStr);
	
		KeyGenerator keyGen = KeyGenerator.getInstance("AES");
		keyGen.init(128);
		Key key = keyGen.generateKey();

		Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
   
		cipher.init(Cipher.ENCRYPT_MODE,key);
		byte[] cipherText = cipher.doFinal(plainText);
		//String cipherTextStr = new String(cipherText, "UTF8");
		//System.out.println(cipherTextStr);
	
		String str = new String(cipherText);
		cipherText = str.getBytes();
		
		cipher.init(Cipher.DECRYPT_MODE,key);
		byte[] newPlainText = cipher.doFinal(cipherText);
	
		String newPlainTextStr = new String(newPlainText, "UTF8");
		System.out.println(newPlainTextStr);
  }
	
} 

⌨️ 快捷键说明

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