#π Need Help with Uni Assignment.
33 messages Β· Page 1 of 1 (latest)
@opaque swallow
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.
And have you tried anything?
!rule hw we won't help you complete the entire thing
And also if we do the entire thing it's like plagiarism
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
What have you learnt from uni?
I used chatgpt but getting error
Otherwise you won't be given the assignment if it's impossible
i just started uni so very new to this
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
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
What code do you have so far?
Sure I will look into these tutorials
What error do you get?
ImportError: cannot import name 'Serpent' from 'Crypto.Cipher'
Show the full code and full Traceback
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()
Hey @opaque swallow!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
i used chatgpt for this code
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?
encryption and decryption project in which I enter a word and it should Encrypt and Decrypt it using Serpent Algorithm.
Do you know what is the serpent algorithm?(Without asking ChatGPT)
Enter it into what? Show the actual spec
π this makes me feel new uni students are so cooked
Consider it's April now, the course probably at least already last for 6 month
Haven't specified anything learnt is concerning for me
- Do you understand what the encryption and decryption function is doing?
- Do you understand what Serpent Cipher does? Don't ask Chat GPT try googling first (also don't read the AI summary on Google search results)
- Instead of implementing Tkinter try from the command line first, only go for something advanced once you're absolutely sure the basic functionality works as intended
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.