필기4지선다보통 · 20점

6666.

다음 Java 코드에서 변수 secret에 값을 대입하는 줄에 있는 보안 약점은? (단, secret은 암호화 키를 저장하는 변수이다.)

1import javax.crypto.Cipher;
2import javax.crypto.spec.SecretKeySpec;
3
4public class Main {
5 public static byte[] encrypt(String text) throws Exception {
6 String secret = "q7Lm2025!aZ#k9Xp";
7 SecretKeySpec spec = new SecretKeySpec(secret.getBytes("UTF-8"), "AES");
8 Cipher cipher = Cipher.getInstance("AES");
9 cipher.init(Cipher.ENCRYPT_MODE, spec);
10 return cipher.doFinal(text.getBytes("UTF-8"));
11 }
12
13 public static void main(String[] args) throws Exception {
14 System.out.println(encrypt("hello").length);
15 }
16}
필기 4과목 · 정보시스템 구축관리★ 1회 출제 · 최근 2020년 3회
정답을 골라 누르면 바로 채점돼요

해설을 먼저 보거나 틀린 뒤 맞히면 필기 점수가 20%만 반영돼요.