20
20
import com .amazonaws .encryptionsdk .keyrings .Keyring ;
21
21
import com .amazonaws .encryptionsdk .keyrings .StandardKeyrings ;
22
22
23
+ import javax .crypto .KeyGenerator ;
23
24
import javax .crypto .SecretKey ;
24
25
import javax .crypto .spec .SecretKeySpec ;
25
26
import java .nio .charset .StandardCharsets ;
@@ -44,9 +45,9 @@ static void encryptAndDecrypt() {
44
45
// 1. Instantiate the SDK
45
46
final AwsCrypto crypto = new AwsCrypto ();
46
47
47
- // 2. Retrieve an encryption key. In this example, we generate a random key.
48
- // In practice, you would get a key from an existing store
49
- final SecretKey cryptoKey = retrieveEncryptionKey ();
48
+ // 2. Get an encryption key. In this example, we generate a random key.
49
+ // In practice, you would get a key from an existing key store
50
+ final SecretKey cryptoKey = generateEncryptKey ();
50
51
51
52
// 3. Instantiate a Raw AES Keyring with the encryption key
52
53
final Keyring keyring = StandardKeyrings .rawAes ()
@@ -98,7 +99,7 @@ static void encryptAndDecrypt() {
98
99
* In practice, this key would be saved in a secure location.
99
100
* For this demo, we generate a new random key for each operation.
100
101
*/
101
- private static SecretKey retrieveEncryptionKey () {
102
+ private static SecretKey generateEncryptKey () {
102
103
SecureRandom rnd = new SecureRandom ();
103
104
byte [] rawKey = new byte [16 ]; // 128 bits
104
105
rnd .nextBytes (rawKey );
0 commit comments