Symmetric Key Encryption
Symmetric encryption is usually considered less safe than asymmetric encryption. This is not because the algorithms are less secure than asymmetric encryption, but because the key that is used to unlock the content must be shared by more than one party. The following diagram illustrates how symmetric encryption works, in general terms.
You can create keys for symmetric encryption in this way:
Key key = KeyGenerator.getInstance(<algorithm>).generateKey();
One of the most popular symmetric encryption methods today is the Advanced Encryption Standard (AES).
Exercise 1: Encrypting the String Using Advanced Encryption Standard
In this exercise, we will encrypt the "My secret message
" string using AES:
- If IntelliJ is already started but no project is open, then select
Create New Project
. If IntelliJ already has a project opened, then selectFile
->New
->Project...