Skip to content

Commit 6696bd2

Browse files
committed
Changed the name and the purpose of this project
1 parent 3035d4f commit 6696bd2

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

file-operations/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# File operations
2+
3+
A lab to some file operations
4+

password-storage/caesar_cipher.py renamed to file-operations/caesar_cipher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from file_utils import remove_accents
2+
13

24
def encrypt(original_message, key):
35
'''
@@ -18,7 +20,7 @@ def encrypt(original_message, key):
1820
key = alphabet.index(key) + 1
1921

2022
# Encrypts the original message then stores in the return variable
21-
for letter in original_message.lower():
23+
for letter in remove_accents(original_message.lower()):
2224
encrypted_letter = ''
2325
if letter not in alphabet:
2426
encrypted_letter = letter

file-operations/file-encrypt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import argparse
2+
from caesar_cipher import encrypt
3+
from file_utils import get_file_content, store_file_content
4+
5+
parser = argparse.ArgumentParser(description='Takes a file as argument and encrypts it')
6+
7+
parser.add_argument('file', type=str)
8+
parser.add_argument('key', type=int)
9+
10+
args = parser.parse_args()
11+
12+
file_content = get_file_content(args.file)
13+
14+
store_file_content(encrypt(file_content, args.key), 'encriptado.txt')

file-operations/file_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from unidecode import unidecode
2+
3+
4+
def remove_accents(string):
5+
return unidecode(string)
6+
7+
def get_file_content(file):
8+
with open(file, 'r') as f:
9+
file_string = f.read()
10+
return file_string
11+
12+
13+
def store_file_content(content, file='new_file.txt'):
14+
with open(file, 'w') as f:
15+
f.write(content)
16+
return f'content stored on {file}'

password-storage/README.md

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

password-storage/file_utils.py

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

0 commit comments

Comments
 (0)