Skip to content

Commit f86db86

Browse files
committed
read base and convert to hash
1 parent 1f9d5cc commit f86db86

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

password-convertion/convertion.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import hashlib
2+
3+
4+
# can test here: http://www.sha1-online.com/
5+
6+
def convert_to_md5(password):
7+
return hashlib.md5(password).hexdigest()
8+
9+
10+
def convert_to_sha1(password):
11+
return hashlib.sha1(password).hexdigest()
12+
13+
14+
def convert_to_sha256(password):
15+
return hashlib.sha256(password).hexdigest()

passwords-base/base-reader.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import csv
2+
import string
3+
4+
def read_password_base():
5+
base_file_path = 'base.txt'
6+
7+
with open(base_file_path, 'r') as csvfile:
8+
base_reader = csv.reader(csvfile, delimiter='|')
9+
return list(base_reader)
10+
11+
def ceaser_decrypt(message, shift):
12+
message = message.lower()
13+
14+
secret = ""
15+
for c in message:
16+
if c in "abcdefghijklmnopqrstuvwxyz":
17+
num = ord(c)
18+
num += shift
19+
if num > ord("z"): # wrap if necessary
20+
num -= 26
21+
elif num < ord("a"):
22+
num += 26
23+
secret = secret + chr(num)
24+
else:
25+
# don't modify any non-letters in the message; just add them as-is
26+
secret = secret + c
27+
return secret
28+
29+
30+
def decrypt_base_password(base):
31+
print "decrypt"
32+
for line in base:
33+
for line in base:
34+
print "before %s" % line[1]
35+
print "after %s" % ceaser_decrypt(line[1], -12)
36+
37+
38+
base = read_password_base()
39+
decrypt_base_password(base)

0 commit comments

Comments
 (0)