Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions Anirudh/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Terminal Chat App is a program which implements asymmetric encryption and decryption along with hashing under the hood.
This program simulates real world processes of key sharing, hashing, symmetric encryption-decryption etc.
13 changes: 13 additions & 0 deletions Anirudh/Terminal Chat App/.idea/Asymmetric-Encryptor-Decryptor.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Anirudh/Terminal Chat App/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Anirudh/Terminal Chat App/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Anirudh/Terminal Chat App/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

184 changes: 184 additions & 0 deletions Anirudh/Terminal Chat App/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions Anirudh/Terminal Chat App/Program Design
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Program Design ->

I. Person Class ->
A. Object Variables
1. Friend list
2. Private key
3. Public key
3. Secured symmetric keys / iv for all friends (list)
4. List of received messages
5. List of sent messages
6. Initialize person in global MESSAGES
B. Object Methods
1. Send message
2. Check message
a. Involves sending key and receiving key
b. Initialize personal messages list in global MESSAGES
c. Initialize person in sent and received messages
4. Send key
5. Receive key
6. Delete Friend
C. Static Variables
1. Public key list

II.User Functions ->
A. Add Person
1. Generate Private Key and Public Key
2. Initializing friend list
3. Adding Public Key to Person Class
4. Add a new log in the terminal
B. Secure Channel
1. Generate a new session key
2. Use asymmetric encryption to share and receive key
3. Add secure symmetric key to each persons list (Secure key/iv list)
4. Add each other to respective friend lists
C. Send Message
1. Send message
2. Add to respective sent and received messages
3. Print appropriate messages on both terminal logs
4. Add Message to global MESSAGES as receiver -> sender -> messages[]
5. Send Hashed Message for verification
D. Check messages
1. Return recent messages
2. Checks if hash of decrypted message matches the hash sent
3. Clear old messages

III. Crypt Class ->
1. Contains all Functionality of the symmetric encryptor
decryptor encapsulated
2. Contains all implementation of padding
3. Contains Asymmetric encryption functionality for key sharing
4. Secure Channel
a. Sends key from sender to receiver
b. receives key from sender and decrypts and verifies

IV. String Class ->
1. Add spaces and remove spaces methods

V. Help menu (Explains commands) ->
1. Add new person using 'add <name>' command
2. To Enter into a specific user use 'select <name>' command
3. Go to help menu using 'help' command
4. List all users using 'list' command
5. Exit the application using 'exit' command

Enter any key to exit this menu

VI. Help menu (Explains user commands) ->
1. Add Friend using 'friend <name>' command
2. Add multiple friends using 'friend <name1> <name2> <name3> ... <nameN>' command
3. Check messages using 'check' command
4. To send a message to a friend use 'send <name> <message>' command
5. To delete a friend use 'delete <friend>' command
6. To go back to main menu using 'main_menu' command
7. Go to help menu using 'help' command
17 changes: 17 additions & 0 deletions Anirudh/Terminal Chat App/Reference files/Alice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
backend = default_backend()
key = os.urandom(32)
iv = os.urandom(16)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
message= "a secret messageabc".encode()
encryptor = cipher.encryptor()
ct = encryptor.update(message) + encryptor.finalize()

#decryptor = cipher.decryptor()
#decryptor.update(ct) + decryptor.finalize()
print(key)
print(iv)
print(message)
print(ct)
21 changes: 21 additions & 0 deletions Anirudh/Terminal Chat App/Reference files/AliceGenerate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
backend=default_backend()


private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048, backend=backend)
public_key = private_key.public_key()
pemprivate = private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption()
)
pempublic = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)

print("Alice")
print(pemprivate)
print(pempublic)
Loading