#πŸ”’ Need Help with Uni Assignment.

33 messages Β· Page 1 of 1 (latest)

opaque swallow
#

I want to make an encryption and decryption project in which I enter a word and it should Encrypt and Decrypt it using Serpent Algorithm. Urgent Help Needed.

vague flintBOT
#

@opaque swallow

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

marble linden
#

And have you tried anything?

opaque swallow
#

I an very beginner. i dont know where to start

#

or what to do

marble linden
#

!rule hw we won't help you complete the entire thing
And also if we do the entire thing it's like plagiarism

vague flintBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

marble linden
#

What have you learnt from uni?

opaque swallow
#

I used chatgpt but getting error

marble linden
#

Otherwise you won't be given the assignment if it's impossible

opaque swallow
marble linden
#

You must have learnt something before the assignment deadline that is relevant

#

!ees if you believe you need to self learn it

#

!res if you believe you need to self learn it

vague flintBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

opaque swallow
robust apex
#

What error do you get?

opaque swallow
robust apex
#

Show the full code and full Traceback

opaque swallow
#
from Cryptodome.Random import get_random_bytes
from Cryptodome.Util.Padding import pad, unpad
import tkinter as tk
from tkinter import messagebox
import base64

# 256-bit (32 bytes) key
key = get_random_bytes(32)
bs = 16  # Block size for Serpent

# Encrypt function
def encrypt_text():
    raw = entry_encrypt.get().encode()
    cipher = Serpent.new(key, Serpent.MODE_ECB)
    ct_bytes = cipher.encrypt(pad(raw, bs))
    ct_base64 = base64.b64encode(ct_bytes).decode()
    output_encrypt.delete(0, tk.END)
    output_encrypt.insert(0, ct_base64)

# Decrypt function
def decrypt_text():
    try:
        ct = base64.b64decode(entry_decrypt.get())
        cipher = Serpent.new(key, Serpent.MODE_ECB)
        pt = unpad(cipher.decrypt(ct), bs).decode()
        output_decrypt.delete(0, tk.END)
        output_decrypt.insert(0, pt)
    except Exception as e:
        messagebox.showerror("Decryption Error", f"Failed to decrypt: {e}")

# GUI setup
app = tk.Tk()
app.title("Serpent Encryption/Decryption")
app.geometry("500x300")

# Encrypt section
tk.Label(app, text="Enter text to encrypt:").pack()
entry_encrypt = tk.Entry(app, width=50)
entry_encrypt.pack()
tk.Button(app, text="Encrypt", command=encrypt_text).pack()
output_encrypt = tk.Entry(app, width=50)
output_encrypt.pack()

# Spacer
tk.Label(app, text="\n").pack()

# Decrypt section
tk.Label(app, text="Enter encrypted text to decrypt:").pack()
entry_decrypt = tk.Entry(app, width=50)
entry_decrypt.pack()
tk.Button(app, text="Decrypt", command=decrypt_text).pack()
output_decrypt = tk.Entry(app, width=50)
output_decrypt.pack()

app.mainloop()
vague flintBOT
#

Hey @opaque swallow!

Please edit your message to use a code block

Add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
opaque swallow
#

i used chatgpt for this code

robust apex
#

Ok well start from scratch without ChatGPT. It hallucinated a library with support for the thing you're supposed to implement

#

What's the spec from the homework?

opaque swallow
marble linden
#

Do you know what is the serpent algorithm?(Without asking ChatGPT)

robust apex
true quail
#

πŸ’€ this makes me feel new uni students are so cooked

marble linden
#

Consider it's April now, the course probably at least already last for 6 month
Haven't specified anything learnt is concerning for mepithink

warm owl
vague flintBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.