๐ Secure/๐ Crypto
-
# python 3 ์ดํ pip install pycrypto # python 3 ์ด์ pip install cryptography pip install pycryptodome
[Python] ์ํธํ ๋ชจ๋ ์ค์น# python 3 ์ดํ pip install pycrypto # python 3 ์ด์ pip install cryptography pip install pycryptodome
2024.01.30 -
RSA ํค ํ์ฑ - ๋ ์์ p,q๋ฅผ ๊ณจ๋ผ์ n=pq๋ก ๋๋๋ค. - e๋ฅผ gcd(phi(n),e) = 1์ด ๋๋๋ก ๋ฝ๋๋ค. phi๋ ์ค์ผ๋ฌ totient ํจ์ - d= eโ1 mod phi(n)์ ๊ณ์ฐํ๋ค. modular inverse๋ e์ ์ ํ์ ์ํด ์ธ์ ๋ ์กด์ฌํ๊ณ , ํ์ฅ๋ ์ ํด๋ฆฌ๋ ํธ์ ๋ฒ์ ์ด์ฉํด ๋น ๋ฅธ ์๊ฐ์์ ๊ณ์ฐ ๊ฐ๋ฅ p, q = ๋ฌด์์๋ก ํฐ ๋ ์์ n = pq phi = (p-1)*(q-1) >> n์ดํ์ n๊ณผ ์๋ก์์ธ ์๋ค์ ๊ฐ์ e = ์ฃผ๋ก 65537 , ๋ค๋ฅธ ๊ฐ์ด ๋๋๋ผ๋ 1
[Crypto] RSA ๋ณตํธํ ์ฆ๋ช ( ์ฌ์ ๋ฆฌ ๅฟ )RSA ํค ํ์ฑ - ๋ ์์ p,q๋ฅผ ๊ณจ๋ผ์ n=pq๋ก ๋๋๋ค. - e๋ฅผ gcd(phi(n),e) = 1์ด ๋๋๋ก ๋ฝ๋๋ค. phi๋ ์ค์ผ๋ฌ totient ํจ์ - d= eโ1 mod phi(n)์ ๊ณ์ฐํ๋ค. modular inverse๋ e์ ์ ํ์ ์ํด ์ธ์ ๋ ์กด์ฌํ๊ณ , ํ์ฅ๋ ์ ํด๋ฆฌ๋ ํธ์ ๋ฒ์ ์ด์ฉํด ๋น ๋ฅธ ์๊ฐ์์ ๊ณ์ฐ ๊ฐ๋ฅ p, q = ๋ฌด์์๋ก ํฐ ๋ ์์ n = pq phi = (p-1)*(q-1) >> n์ดํ์ n๊ณผ ์๋ก์์ธ ์๋ค์ ๊ฐ์ e = ์ฃผ๋ก 65537 , ๋ค๋ฅธ ๊ฐ์ด ๋๋๋ผ๋ 1
2023.10.11 -
๋ณดํธ๋์ด ์๋ ๊ธ์ ๋๋ค.
[Crypto] RSA ๊ณต๊ฒฉ๋ฒ ( ์ฌ์ ๋ฆฌ ๅฟ )๋ณดํธ๋์ด ์๋ ๊ธ์ ๋๋ค.
2023.10.11 -
1. ๊ธฐ์ด ๋ธ๋ก ๋ง๋ค๊ธฐ ๋ธ๋ก์ ๊ฐ๊ฐ์ ๋ฐ์ดํฐ ๊ฐ์ ๊ฐ์ง๋ค - timestamp : ์ธ์ ๋ง๋ค์ด ์ก๋์ง - hash : ํ์ฌ ๋ธ๋ก์ ํด์ ๊ฐ - previous hash : ์ด์ ๋ธ๋ก์ ํด์ ๊ฐ - nonce : ๋ ผ์ค - transaction : ์ค์ ๋ฐ์ดํฐ ์ ๋ณด์ธ ํธ๋์ ์ class Block: def __init__(self, transactions, previous_hash, nonce = 0): self.timestamp = datetime.now()#datetime.now()๋ฅผ ์ฌ์ฉํด์ ํ์ฌ ๊ฐ์ timestamp self.transactions = transactions self.previous_hash = previous_hash self.nonce = nonce self.hash = self..
[Crypto] Python | ๋ธ๋ก์ฒด์ธ ์ดํดํ๊ธฐ1. ๊ธฐ์ด ๋ธ๋ก ๋ง๋ค๊ธฐ ๋ธ๋ก์ ๊ฐ๊ฐ์ ๋ฐ์ดํฐ ๊ฐ์ ๊ฐ์ง๋ค - timestamp : ์ธ์ ๋ง๋ค์ด ์ก๋์ง - hash : ํ์ฌ ๋ธ๋ก์ ํด์ ๊ฐ - previous hash : ์ด์ ๋ธ๋ก์ ํด์ ๊ฐ - nonce : ๋ ผ์ค - transaction : ์ค์ ๋ฐ์ดํฐ ์ ๋ณด์ธ ํธ๋์ ์ class Block: def __init__(self, transactions, previous_hash, nonce = 0): self.timestamp = datetime.now()#datetime.now()๋ฅผ ์ฌ์ฉํด์ ํ์ฌ ๊ฐ์ timestamp self.transactions = transactions self.previous_hash = previous_hash self.nonce = nonce self.hash = self..
2023.09.20 -
from random import randint # ์๋ก ๋ค๋ฅธ 2๊ฐ์ ์์ ๊ณ ๋ฅด๊ธฐ def is_prime(n): if n
[Crypto] Python | RSA ์ํธ ์๊ณ ๋ฆฌ์ฆ ์ ์ฉ ์ฝ๋ + ์์ from random import randint # ์๋ก ๋ค๋ฅธ 2๊ฐ์ ์์ ๊ณ ๋ฅด๊ธฐ def is_prime(n): if n
2023.09.12 -
from Crypto.Util.number import getPrime from gmpy2 import invert # ํ์ด์ฌ์์ p, q ๊ฐ์ ์์ฑํ๋ ๋ฐฉ๋ฒ p = getPrime(1024) #1024 bit / ๋ฌด์์๋ก ํฐ ๋ ์์ p, q ๊ณ ๋ฅด๊ธฐ q = getPrime(1024) # n ๊ฐ ๊ณ์ฐํ๋ ๋ฒ n = p * q # n ์ดํ์ n๊ณผ ์๋ก์์ธ ์๋ค์ ๊ฐ์ ๊ณ์ฐ phi = (p - 1) * (q - 1) # 1
[Crypto] Python | RSA ์ํธ ์๊ณ ๋ฆฌ์ฆ ๊ตฌ์ถfrom Crypto.Util.number import getPrime from gmpy2 import invert # ํ์ด์ฌ์์ p, q ๊ฐ์ ์์ฑํ๋ ๋ฐฉ๋ฒ p = getPrime(1024) #1024 bit / ๋ฌด์์๋ก ํฐ ๋ ์์ p, q ๊ณ ๋ฅด๊ธฐ q = getPrime(1024) # n ๊ฐ ๊ณ์ฐํ๋ ๋ฒ n = p * q # n ์ดํ์ n๊ณผ ์๋ก์์ธ ์๋ค์ ๊ฐ์ ๊ณ์ฐ phi = (p - 1) * (q - 1) # 1
2023.09.11