一、导语
JAVA体系专栏,帮您从头开始梳理知识点,方便新手串联有价值的学习,老手按需复习。让我们体验一下打怪升级般的学习吧。好了,废话不多说。做好了开始发车喽!
1. 安全进阶
- 零信任架构:永不信任,始终验证。
- 密码学:RSA 非对称加密、AES 对称加密、SHA‑256 哈希、数字签名。
- 容器安全:镜像扫描(Trivy)、运行时防护(Falco)。
练习:实现基于 RSA 的数据加解密工具,公钥加密、私钥解密。
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.util.Base64;
import javax.crypto.Cipher;
public class RSAEncryptDecrypt {
public static void main(String[] args) throws Exception {
// 生成 RSA 密钥对
KeyPair keyPair = generateKeyPair();
PublicKey publicKey = keyPair.getPublic();
PrivateKey privateKey = keyPair.getPrivate();
String originalText = "Hello, World!";
// 加密
String encryptedText = encrypt(originalText, publicKey);
System.out.println("Encrypted Text: " + encryptedText);
// 解密
String decryptedText = decrypt(encryptedText, privateKey);
System.out.println("Decrypted Text: " + decryptedText);
}
private static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
SecureRandom secureRandom = new SecureRandom();
keyPairGenerator.initialize(2048, secureRandom);
return keyPairGenerator.generateKeyPair();
}
private static String encrypt(

最低0.47元/天 解锁文章
1614

被折叠的 条评论
为什么被折叠?



