Missing Semester: Security and Cryptography

Author

Heeyoung Kim

Published

January 31, 2023

아래 노트북은 MIT에서 제공하는 Missing semester의 연습문제를 풀이한 것입니다. 이번 내용은 셸 툴 및 스크립팅(Shell Tools and Scripting) 에 대한 것입니다.

1. Entropy

  1. Suppose a password is chosen as a concatenation of four lower-case dictionary words, where each word is selected uniformly at random from a dictionary of size 100,000. An example of such a password is correcthorsebatterystaple. How many bits of entropy does this have?
import numpy as np
np.log2(100000**3)
49.82892142331043
  1. Consider an alternative scheme where a password is chosen as a sequence of 8 random alphanumeric characters (including both lower-case and upper-case letters). An example is rg8Ql34g. How many bits of entropy does this have?

26 letters in lower-case and upper-case each(52 letters total). And there is 10 digits from 0 to 9. So 62 letters could be used in one character. rg8Ql34g is 8 characters.

np.log2(62**8)
47.633570483095
  1. Which is the stronger password?

correcthorsebatterystaple is more stronger than rg8Ql34g.

  1. Suppose an attacker can try guessing 10,000 passwords per second. On average, how long will it take to break each of the passwords?
print(f'{100000**3 / 10000 / 60 / 60 / 24 / 365} years for "correcthorsebatterystaple" \n{62**8 / 10000 / 60 / 60 / 24 / 365} years for "rg8Ql34g"')
3170.9791983764585 years for "correcthorsebatterystaple" 
692.3519329810249 years for "rg8Ql34g"