Python-Projects icon indicating copy to clipboard operation
Python-Projects copied to clipboard

Encrypt and Decrypt Chats in The LocalChat app to prevent non users From listening In

Open 5enox opened this issue 2 years ago • 18 comments

Encrypt and Decrypt messages between server and client using the private key plus something else to make it more secure.

5enox avatar Jan 01 '24 18:01 5enox

I'd like to be assigned For This Issue

5enox avatar Jan 01 '24 18:01 5enox

@5enox is this issue still open? I would also like to contribute to it.

Ishpreet01 avatar Jan 18 '24 19:01 Ishpreet01

Yeah, sure

5enox avatar Jan 19 '24 12:01 5enox

@5enox Please assign this issue to me. I would like to work on this.

Ishpreet01 avatar Jan 20 '24 07:01 Ishpreet01

@Shahrayar123 , could you please assign this issue to @Ishpreet01 ? Thank you!

5enox avatar Jan 20 '24 11:01 5enox

@5enox I am not able to run the command python3 main.py in my system to set up this project. Please help me out. Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.-This is the message that I am getting in the terminal after running the command.

Ishpreet01 avatar Jan 23 '24 19:01 Ishpreet01

@Ishpreet01 try re-installing python, But this time check the box where it says Add to Path also use only python main.py on windows

0_7nOyowsPsGI19pZT

or if you're on linux : sudo apt update and then sudo apt install python3

5enox avatar Jan 24 '24 10:01 5enox

@5enox I added python to path and used python main.py command to run the project. But the terminal does not display the text Anon Chat and stops working after I run the command. I am attaching the screenshot for your reference. Please tell me how to proceed further with this.

image

Ishpreet01 avatar Jan 25 '24 07:01 Ishpreet01

@5enox I used this command to run the Number Guessing game project and it worked perfectly for that. image

Ishpreet01 avatar Jan 25 '24 07:01 Ishpreet01

@5enox is this issue still open? I would also like to contribute to it.

Harshita1375 avatar Mar 23 '24 10:03 Harshita1375

@Harshita1375 Please Go ahead, if you need any assistance Just mention me

5enox avatar Mar 26 '24 17:03 5enox

@Harshita1375 Please Go ahead, if you need any assistance Just mention me

Which repository do I need to fork as I am not able to find Encrypt and Decrypt project in this repository?.

Harshita1375 avatar Mar 27 '24 14:03 Harshita1375

@Harshita1375 Right Here

5enox avatar Mar 27 '24 16:03 5enox

@5enox can you assign this issue to me, i would like to contribute. I have only one question, are we decrypting the message on client side only, like end to end?

Sangamesh-RK avatar Apr 30 '24 20:04 Sangamesh-RK

@Shahrayar123 Can Assign You @Sangamesh-RK , and Yes, The encryption Should Be End to end between the clients.

Here is a Starter Sample You Could Look at, using the Signal Protocol in Python ( Used By Whatsapp)

from axolotl import axolotl_curve25519 as curve
from axolotl.state import PreKeyBundle, AxolotlState

# Sender's identity key pair
sender_identity_key_pair = curve.generateIdentityKeyPair()

# Sender's pre key pair
sender_pre_key_pair = curve.generatePreKey()

# Recipient's identity key pair
recipient_identity_key_pair = curve.generateIdentityKeyPair()

# Recipient's pre key pair
recipient_pre_key_pair = curve.generatePreKey()

# Sender creates a pre key bundle to send to recipient
sender_pre_key_bundle = PreKeyBundle(sender_identity_key_pair.getPublicKey(), sender_pre_key_pair.id(), sender_pre_key_pair.getPublicKey())

# Sender encrypts a message
sender_session_builder = AxolotlState(curve.generateSenderKeyDistributionMessage(sender_pre_key_bundle, recipient_identity_key_pair.getPublicKey(), recipient_pre_key_pair.id(), recipient_pre_key_pair.getPublicKey()))
sender_session_builder.processPreKey(sender_pre_key_bundle)
cipher_text = sender_session_builder.encrypt(b"Hello, recipient!")

# Recipient decrypts the message
recipient_session_builder = AxolotlState()
recipient_session_builder.processPreKey(sender_pre_key_bundle)
recipient_session_builder.processSenderKeyDistributionMessage(cipher_text)
plain_text = recipient_session_builder.decrypt(cipher_text)

print("Decrypted message:", plain_text.decode())

Make Sure you have python-axolotl-curve25519 installed (pip install python-axolotl-curve25519) before running this code.

5enox avatar May 01 '24 19:05 5enox

Make Sure you have python-axolotl-curve25519 installed (pip install python-axolotl-curve25519) before running this code.

i looked into the above module, apparently its used for E2E communication between two clients which is different from our use case, i will try to implement it for group chat but i would appreciate if you can guide me

Sangamesh-RK avatar May 02 '24 06:05 Sangamesh-RK

i am having a lot of import issues with axolotl module, image When i googled, i found out that this is a common issue for windows user. i tried following steps but wasn't able to resolve this as this requires python 2.7 but pip doesn't supports older version of Python now

can i use this module instead https://pypi.org/project/signal-protocol/ ?

Sangamesh-RK avatar May 02 '24 14:05 Sangamesh-RK