Class AppInitializer.java có nhiệm vụ sẽ tự động tạo cặp public key và private key mỗi khi chương trình được khởi chạy và lưu chúng vào trong Context của ứng dụng
Ở trong file jsp sẽ thực hiện lấy context bằng cách
Gắn link thư viện JSEncrypt <script src="https://cdnjs.cloudflare.com/ajax/libs/jsencrypt/3.0.0-beta.1/jsencrypt.min.js"></script>
Thực hiện tạo đối tượng JSEncrypt và truyền key vào. Gọi phương thức encrypt để thực hiện mã hóa dữ liệu
Ở trong file java sẽ thực hiện lấy context bằng cách PrivateKey privateKey = (PrivateKey) req.getServletContext().getAttribute("PRIVATE_KEY");
Giải pháp: RSA
Ở trong file jsp sẽ thực hiện lấy context bằng cách Gắn link thư viện JSEncrypt
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsencrypt/3.0.0-beta.1/jsencrypt.min.js"></script>
Thực hiện tạo đối tượng JSEncrypt và truyền key vào. Gọi phương thức encrypt để thực hiện mã hóa dữ liệuỞ trong file java sẽ thực hiện lấy context bằng cách
PrivateKey privateKey = (PrivateKey) req.getServletContext().getAttribute("PRIVATE_KEY");