
데이터를 안전하게 전달 혹은 보관하기 위해서 여러 암호화 알고리즘이 사용된다. 암호화 알고리즘에는 대칭키 방식과 비대칭키 방식 그리고 단방향 암호화가 있다.
보안의 3요소


각 암호화의 장점을 채택하여 용량이 큰 정보는 대칭키로 암호화하고, 암호화에 사용된 대칭키는 공개키로 암호화하여 대상에게 전달하는
하이브리드 암호화 방법이 일반적으로 사용되고 있다.
공개키 기반 구조
특정 사람의 개인키와 공개키는 어떻게 생성, 배포, 관리해야 하는가에 대한 이슈가 존재한다. 또한, 어떤 공개키가 특정한 사람의 공개키라는 것을 어떻게 보장할 수 있는지에 대한 이슈도 존재한다.
이를 해결하기 위해디지털 인증서를 도입했고 이를 활용하는 소프트웨어, 하드웨어, 정책, 제도, 사용자 등을 총칭해서공개키 기반 구조라고 한다.
최근 프로젝트에서 민감한 데이터를 전달할 일이 생겼고, Crypto 라이브러리를 사용하여 AES-256 암복호화 함수를 구현해서 사용했다.
여기서 key는 암호화에 사용할 비밀키이고, iv는 CBC모드에서 첫 번째 블록을 암호화할 때 사용되는 초기 벡터이다.
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class Encrypt {
public static String alg = "AES/CBC/PKCS5Padding";
// 암호화
public static String encryptAES256(String key, String iv, String text) throws Exception {
Cipher cipher = Cipher.getInstance(alg);
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES");
IvParameterSpec ivParamSpec = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivParamSpec);
byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8"));
return Base64.getEncoder().encodeToString(encrypted);
}
// 복호화
public static String decryptAES256(String key, String iv, String cipherText) throws Exception {
Cipher cipher = Cipher.getInstance(alg);
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "AES");
IvParameterSpec ivParamSpec = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivParamSpec);
byte[] decodedBytes = Base64.getDecoder().decode(cipherText);
byte[] decrypted = cipher.doFinal(decodedBytes);
return new String(decrypted, "UTF-8");
}
}
https://github.com/WooVictory/Ready-For-Tech-Interview/blob/master/Network/공개키%20%26%20대칭키.md
Real Madrid will soon be at full strength ahead of their clash with Atalanta in the 2024 UEFA Super Cup on Thursday (15/8/2024) early morning. El Real's new star, Kylian Mbappe, has the opportunity to make his debut soon.
https://www.nobartv.co.id/indeks-topik , https://en.nobartv.co.id/indeks-topik , https://ko.nobartv.co.id/indeks-topik , https://ja.nobartv.co.id/indeks-topik , https://ar.nobartv.co.id/indeks-topik , https://hi.nobartv.co.id/indeks-topik
Mbappe is known to have joined the team training. The former Paris Saint-Germain (PSG) striker previously spent a long holiday after playing in EURO 2024. Mbappe has not had the chance to participate in the 2024/2025 pre-season trial series, even though he was introduced at the Santiago Bernabeu long ago.
https://ru.nobartv.co.id/indeks-topik , https://es.nobartv.co.id/indeks-topik , https://th.nobartv.co.id/indeks-topik , https://fr.nobartv.co.id/indeks-topik
Real Madrid also has the opportunity to be strengthened again by Jude Bellingham, Federico Valverde, Eduardo Camavinga, Dani Carvajal, Ferland Mendy, and Aurelien Tchouameni. The list of names received a long break, because they just appeared at EURO and Copa America 2024.