본문 바로가기

Computer Science/Security Programming

II Pycryptodome

 

2024.09.0.9.MON

 

PyCharm

Pycryptodome

AES_Test.py

from Crypto.Cipher import AES.   # import Crypto.Cipher/AES.py 동일한 의미

from Crypto.Random import get_random_bytes

 

data = 'hello world'.encode()

data1 = 'hello world'.encode('utf-8') #위와 동일한 의미

data2 = b'hello world'.  #바이트 스트림 형태로 받는 것

 

# AES 128 bits or 256 bits key generate

aes_key = '0123456789012345' #16바이트, 이런식으로 하나의 랜덤한 스트림을 만드는 것과 같이 iv를 만들 수 있다.

iv = get_random_bytes(16)   ### 16의 의미 = 128bits임을 의미한다.

print('aes_key:', aes_key) # encoding

print('iv:', iv) # encoding

 

cipher = AES.new(aes_key, AES.MODE_CFB, iv)  ## AES object 

ciphertext = cipher.encrypt(data) ### data 라는 평문에 대한 -> AES 암호문을 생성하는 것

print(:ciphertext:", ciphertext)

 

cipher2 = AES.new(aes_key, AES.MODE_CFB, iv)

plaintext = cipher2.decrypt(ciphertext)  ### ciphertext AES 복호화 --> 평문

print("plaintext:", plaintext.decode())

 

 

이것이 가장 기본적으로 보안과 관련된 라이브러리를 이용해 간단하게 메시지를 인크립션하고 디크립션하는 과정이다.

 

 


 

2024.09.11.WED

 

파이썬 프로그래밍 구조 개요

국문/영문판 교재

Python By Example - Nichola Lacey

 

Python

- Python 1991년 귀도 반 로섬(Guido van Rossum)이 개발한 대화형 프로그래밍 언어

PYPL PopularitY of Programming Language

특징

1) 스크립트 언어(Script language)

2) 동적 타이핑(Dynamic typing)

3) 플랫폼 독립적(Platform-independent)

 

장점

1. 간결하고 쉬운 문법

2. 빠른 개발 속도

3. 높은 확장성 및 이식성

4. 활발한 생태계 (보안, 해킹, 웹사이트, 데이터사이언스.etc)

 

Python 활용 사례

Google : 백엔드에 C++ 와 Python 사용하여 서비스 구축

• Instagram : Python + Django 기반 서버 구축/운영

• Netflix : 표준라이브러리/구문/커뮤니티 Python으로 구축

• Spotify : 음악 스트리밍/미디어 서비스 Python으로 구축

• Dropbox : 사진/문서/파일보관/공유 등 Python으로 구축

 

 

 

string, error, 파이썬은 대소문자를 구별한다, var = int(input()) 등 진도