Algorithm
-
[비대칭키 알고리즘] DH, RSA의 수학적 자물쇠와 그 취약점 보완Algorithm 2024. 4. 17. 01:30
들어가며 HTTPS의 주요 기술인 '키 교환'과 '디지털 서명'은 '비대칭키' 알고리즘을 사용합니다. 비대칭키는 '개인키'-'공개키' 쌍으로 이루어진 키를 말하는데, 공개키는 말 그대로 누구에게나 공개되는 반면, 개인키는 비밀로 유지되어야 합니다. 이 글에서는 키 교환과 디지털 서명의 대표적인 알고리즘인 DH(Diffie-Hellman)와 RSA(Riveset-Shamir-Adelman)를 다룹니다. 비대칭키 방식의 DH와 RSA는 정방향으로 계산하기 쉽지만 역방향 계산은 어려운 '일방향 함수'의 개념을 활용합니다. 예를 들어, 큰 두 수의 곱셈은 쉽지만 큰 합성수에 대한 소인수 분해는 어렵습니다. 이와 같이 DH로 생성된 대칭키를 유추하거나, RSA로 암호화된 데이터를 복호화하려면 매우 어려운 역 연..
-
코드트리 사용 후기 #2Algorithm 2024. 4. 6. 23:50
벌써 코드트리를 사용해본지 두 달이 되었네요. 두달 동안 코드트리를 사용해본 결과, 제가 지속적으로 느낀 코드트리의 차별화된 특장점으로 '상세한 개념 설명'과 '질문에 대한 빠른 피드백'을 꼽아봤습니다. 장점 1. 상세한 개념 설명 코드트리의 커리큘럼은 '프로그래밍 기초' - '프로그래밍 연습' - '자료구조・알고리즘' - '알고리즘 입문' - '알고리즘 기본' - '알고리즘 실전'으로 구성되어있습니다. 저는 첫 달에 실력 진단 결과에 따라 '알고리즘 입문'으로 시작했습니다. 그래서 '알고리즘 입문'을 마스터한 후 두번째 달에는 '알고리즘 기본'까지 끝낼 계획이었지만, 문제 풀이에 있어서 친절한 개념 설명의 도움을 많이 받고있다는 것을 체감하고는 개념 설명이 위주인 '프로그래밍 기초'로 커리큘럼을 변경했..
-
코드트리 사용 후기 #1Algorithm 2024. 3. 2. 23:50
알고리즘 학습 사이트들인 백준, 리트코드, 프로그래머스의 구천을 떠돌아다던 제가 마침내 코드트리에 정착하기로 결심한 경험을 공유하겠습니다. 저는 어려운 문제를 만났을 때 한 문제에 4~5시간씩 매달려서 다른 일을 못 하게 되곤 했습니다. 더 심각한 날은 그 정도의 시간을 투자했는데 결국 문제를 못 푸는 날도 있었습니다. 알고리즘 문제 푸는 날은 알고리즘만 하게 되는 날, 나아가 성과가 아무 것도 없는 최악의 날이 될 수도 있다는 인식이 생겨서 아침부터 굉장한 스트레스를 받곤 했습니다. 그래서 다른 플랫폼으로 옮기면 다시 전의가 불타오르지 않을까 싶은 마음에 애꿎은 학습 플랫폼만 옮겨다녔었습니다. 사실 글또에서 '코드트리 × 글또 블로그 챌린지'를 운영한다고 하셨을 때 플랫폼에 대한 기대는 별로 없었고 '..
-
백준 # 15736Algorithm 2023. 12. 7. 10:55
https://www.acmicpc.net/problem/15736 15736번: 청기 백기예제 입력 1의 경우 1, 2, 3번 깃발이 존재하고, 3명의 선수가 참가한다. 첫 번째 선수는 1의 배수의 번호를 가진 깃발을 뒤집는다. 초기에 청색이였던 깃발은 첫 번째 선수에 의해 모두 백기로 된www.acmicpc.net 나의 풀이n = int(input())answer = 0flags = [0] * n# n명이 n개의 깃발을 각 순서의 배수만큼 뒤집은 결과 리스트 for i in range(1, n+1): for j in range(1, n+1): if j*i 모범 답안패턴을 발견해보자!n 이하의 가장 큰 제곱수를 구하면 된다 12345678최초 깃발 상태oooooooo1번 학생이 깃발을 뒤집은 ..
-
백준 # 14568Algorithm 2023. 12. 6. 02:06
https://www.acmicpc.net/problem/14568 14568번: 2017 연세대학교 프로그래밍 경시대회 규칙에 맞게 사탕을 분배하는 경우의 수를 출력한다. 택희, 영훈이, 남규가 받은 사탕의 수를 각각 A, B, C개라고 할 때, 서로 다른 (A, B, C) 순서쌍의 수를 세면 된다. 만일 규칙에 맞게 사탕을 분 www.acmicpc.net 시간 초과로 답을 본 후 풀이 n = int(input()) answer = 0 # 세 명에게 n개의 사탕을 나눠주는 모든 경우의 수 for i in range(1, n + 1): for j in range(1, n + 1): for k in range(1, n + 1): # 주어진 조건을 모두 만족시키기 위해 중첩조건문을 사용 if i + j + ..
-
백준 #1816Algorithm 2023. 12. 5. 19:48
https://www.acmicpc.net/problem/1816 1816번: 암호 키 현대 사회에서 통용되고 있는 많은 종류의 암호 시스템에서는, 매우 큰 소수의 곱으로 만들어진 수를 암호 키로 이용하는 경우가 많다. 현실적으로 매우 큰 수를 빠른 시간 내에 소인수분해하는 www.acmicpc.net 나의 풀이 def rtn_primes(num): """ input(비밀번호)에 대한 모든 소인수를 요소로 갖는 리스트 반환 """ primes = [] i = 2 while i == num: if num % i == 0: primes.append(i) i += 1 return primes # 주어진 횟수를 요소의 길이로 갖는 비밀번호 리스트 생성 num = int(input()) password_list ..