Skip to content

Commit ca3c682

Browse files
committed
restructuring repo
1 parent beace00 commit ca3c682

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+344
-318
lines changed

Cesar_Cipher/Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Caesar Cipher- Cryptography with Python
2+
3+
## Overview:
4+
5+
Caesar Cipher is one of most easiest and simplest encryption methods. It is a stype of substitution cipher.
6+
It works by shifting each character of the input string by a given value down the alphabetical order.
7+
8+
Example: Upon giving a shift key of 2, A would be replaced by C, B by D and so on.
9+
10+
<p align = "center">
11+
<img src="caesar_cipher.jpg" alt="caesar_cipher">
12+
</p>
13+
14+
## Output:
15+
16+
<p align = "left">
17+
<img src="output.jpg" alt="output">
18+
</p>

Cesar_Cipher/caesar_ciper.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
''' A python program that implements Caesar Cipher Technique- Cryptography'''
2+
3+
def encryption(string,key): #function definition
4+
''' Function that encrypts the given string using caesar cipher technique
5+
Params: string, key
6+
Returns: encrypted_text
7+
'''
8+
encrypted_text=''
9+
for char in string:
10+
if char=='':
11+
encrypted_text+=char
12+
#Encrypts Empty character
13+
14+
elif char.isupper():
15+
encrypted_text= encrypted_text+ chr((ord(char) + key-65) % 26 + 65)
16+
#Encrypts Upper case character
17+
18+
else:
19+
encrypted_text=encrypted_text+ chr((ord(char) + key-97) % 26 + 97)
20+
#Encrypts lower case character
21+
22+
return encrypted_text
23+
24+
if __name__== "__main__":
25+
string=input('Enter the text to be encrypted:')
26+
key=int(input('Enter the shift key:'))
27+
print('Text before Encryption:',string)
28+
print('Shift Key:',key)
29+
print('Encrypted text:',encryption(string,key)) #function calling
30+
31+
'''
32+
Sample Output:
33+
Enter the text to be encrypted:Alphabets ABCD
34+
Enter the shift key:4
35+
Text before Encryption: Alphabets ABCD
36+
Shift Key: 4
37+
Encrypted text: EptlefixwrEFGH
38+
39+
'''
40+

Cesar_Cipher/caesar_cipher.jpg

36.3 KB
Loading

Cesar_Cipher/output.jpg

22.9 KB
Loading

HTML_to_Markdown/README.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

HTML_to_Markdown/how_to_use.PNG

-10.7 KB
Binary file not shown.

HTML_to_Markdown/html_to_markdown.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

HTML_to_Markdown/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

HTML_to_Markdown/sample.PNG

-83.6 KB
Binary file not shown.

Hashing_file/app.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import sys
2+
import hashlib
3+
4+
methods = {
5+
'1':'md5',
6+
'2':'sha1',
7+
'3':'sha256',
8+
'4':'sha512',
9+
}
10+
11+
def help():
12+
print("Usage: python app.py filename")
13+
print("""
14+
Available hash methods
15+
[1] MD5
16+
[2] SHA1
17+
[3] SHA256
18+
[4] SHA512
19+
""")
20+
21+
22+
def file_read(filename):
23+
try:
24+
content = open(filename, "r").read()
25+
content = content.encode('utf-8')
26+
return content
27+
except:
28+
print("Openning file error")
29+
exit(0)
30+
31+
def hash_text(content,method):
32+
return hashlib.new(methods[method],content).hexdigest()
33+
34+
35+
def write_content(hashed_content):
36+
new_file=open('Hased data.txt','w')
37+
new_file.write(hashed_content)
38+
new_file.close()
39+
print("Done writing data to file hash data.txt")
40+
41+
if __name__ == "__main__":
42+
help()
43+
if len(sys.argv) < 2:
44+
help()
45+
print("No file specified")
46+
exit(0)
47+
48+
filename = sys.argv[1]
49+
50+
content = file_read(filename)
51+
method=int(input())
52+
if(method > 4 or method < 1):
53+
print("No method or wrong method specified. Using default md5 hashing method")
54+
method = 1
55+
56+
hashed_content = hash_text(content,str(method))
57+
58+
write_content(hashed_content)

0 commit comments

Comments
 (0)