r/PythonLearning • u/Electronic_Mine6521 • Jul 11 '25
my first project
I started python two weeks ago and this project , it s a close to RSA encryption , i m new to this so if you have any advice for making it more efficient i would love help .
7
u/animatedgoblin Jul 11 '25
I know you're just doing this for learnings sake, but never roll your own cryptography implementation. It is almost guaranteed to contain bugs or errors that can break the encryption. Use known recommended libraries instead
2
u/SizzlingSquigg Jul 11 '25
Looks like you’re practicing a lot of nice ideas like hashmaps, functions, & chaining functions. Nice work!
Dont be afraid to name things. The next time you read this code, you might ask “what is function m or p? What does n stand for? What is value s & why do I cast it to an int?” etc. Code is both literature and art!
Or maybe I’m just not educated on encryption and this naming convention is popular amongst cryptographers
1
2
u/purple_hamster66 Jul 13 '25
Name variables and functions with what they do, not with single letters. Comments are used to state what each function is supposed to compute, to declare your goals (speed, simple code, experiment, class project), lay out your chosen methods at a high level (use lib XYZ; implement a faster version of AES), the reason you wrote this, and the URL, book, or article you got the ideas from. Leave bread crumbs for your future self — you will totally forget all those things in 6-12 months. Comments also make your code searchable when you’ve got 100 files and need to find one but forgot all the variables and function names.
2
u/FitnessGuy4Life Jul 17 '25
Anybody can write an algorithm, but good code is code that other developers can understand and modify easily.
Try giving descriptive names to functions and variables. They should describe exactly what theyre doing. You arent programming for a computer, youre programming for other developers.
1
u/skeetd Jul 12 '25
Where is the docstring? :)
Kidding aside that looks like fun, always loved cyphers
1
u/usama015 Jul 12 '25
I wanna learn too, but I'm stuck in a tutorial hell. Can you suggest some resources.
2
u/PalpitationDecent282 Jul 12 '25
You've probably heard this before, but you really just have to build your own projects. Learn the basics and then figure out what you want to do, you're better off narrowing your research to one thing at a time.
You can look at as many tutorials as you want, but if you aren't going to use the information you gain you won't actually learn anything. I mean, what do you gain from knowing how to fly a plane when you specialize in driving? Why didn't you just build more skills in driving instead?
1
u/usama015 Jul 12 '25
When i try to build some projects and do some little exercise on some concepts , I wasn't able to get the right functions or methods like what loop I should use , how these gonna work , and how to build this or that . I just get stuck in that point 😞
3
u/PalpitationDecent282 Jul 12 '25
It sounds like you're just looking at what the syntax does rather than how it works and when it should be used. Have you tried looking at the python docs? If you need help with something specifically feel free to DM me.
1
1
u/Intelligent_Count316 Jul 12 '25
Wow this is great. I started in April but I'm still struggling. I know the basics, Oop, import modules, file I/o. What more should I learn to get confident?
1
u/Actual-Bank1486 Jul 14 '25
instead of having cryptic as a function you should make it a class. Also, its usually best practice to import outside your function. Overall, very good job keep up the good work.
1
u/Tricky_Ferret2399 Jul 15 '25
I need ideas on what projects to try to write. I’m not very good on thinking of things to do
1
0
u/DwightBaxter Jul 12 '25
Super cool! I'll get there one day....
2
u/Agitated-Soft7434 Jul 12 '25
What's keeping ya from doing it now? I'm sure you got this 👍!
1
u/DwightBaxter Jul 12 '25
Im still learning but I'm also a hobbiest. All of my python is done in my free time
2
u/Agitated-Soft7434 Jul 12 '25
My favourite way to learn things! -and your right your definitely gonna get there one day! I wish ya good luck on your coding journey :D
0
u/Some-Passenger4219 Jul 12 '25
Use scientific notation for the powers of ten; e.g. 1e7 for ten million. "Readability counts."
0
Jul 12 '25
[deleted]
1
u/Electronic_Mine6521 Jul 12 '25
I learned the basics from YouTube tutorials and then practiced and still practicing doing problems not leetcode just random ideas that come to mind i study maths a lot so all i try to do is to apply all that math theory into projects
7

13
u/Cerus_Freedom Jul 11 '25
The letter/number map is not required. You can use ord() to get the ASCII value of a character as an integer.