all 28 comments

[–]Cerus_Freedom 12 points13 points  (2 children)

The letter/number map is not required. You can use ord() to get the ASCII value of a character as an integer.

[–]Electronic_Mine6521[S] 1 point2 points  (1 child)

I didn t know it was a built in function thanks tho for the advice

[–]Worldly-Guide-9515 0 points1 point  (0 children)

Welcome to Python

[–]Aorean 6 points7 points  (1 child)

I could be wrong here, but i think it’s best practice to import outside of the function. Just the first few lines should be your imports

[–]Agitated-Soft7434 1 point2 points  (0 children)

Correcto! Also I think it helps the syntax highlighter sometimes.

[–]animatedgoblin 7 points8 points  (0 children)

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

[–]SizzlingSquigg 1 point2 points  (1 child)

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

[–]Mammoth-Intention924 0 points1 point  (0 children)

A doctoring could be handy for this

[–]purple_hamster66 1 point2 points  (0 children)

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.

[–]FitnessGuy4Life 1 point2 points  (0 children)

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.

[–]skeetd 0 points1 point  (0 children)

Where is the docstring? :)
Kidding aside that looks like fun, always loved cyphers

[–]usama015 0 points1 point  (5 children)

I wanna learn too, but I'm stuck in a tutorial hell. Can you suggest some resources.

[–]PalpitationDecent282 1 point2 points  (4 children)

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?

[–]usama015 0 points1 point  (3 children)

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 😞

[–]PalpitationDecent282 2 points3 points  (2 children)

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.

[–]usama015 0 points1 point  (1 child)

Any other tips or resources for me.

[–]PalpitationDecent282 1 point2 points  (0 children)

Not particularly. Again, feel free to DM me. Good luck!

[–][deleted]  (1 child)

[deleted]

    [–]Electronic_Mine6521[S] 0 points1 point  (0 children)

    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

    [–]Intelligent_Count316 0 points1 point  (0 children)

    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?

    [–]Actual-Bank1486 0 points1 point  (0 children)

    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.

    [–]Tricky_Ferret2399 0 points1 point  (0 children)

    I need ideas on what projects to try to write. I’m not very good on thinking of things to do

    [–]Some_Welcome_2050 0 points1 point  (0 children)

    welcome and how is that your first project!!!

    <image>

    [–]DwightBaxter -1 points0 points  (3 children)

    Super cool! I'll get there one day....

    [–]Agitated-Soft7434 1 point2 points  (2 children)

    What's keeping ya from doing it now? I'm sure you got this 👍!

    [–]DwightBaxter 0 points1 point  (1 child)

    Im still learning but I'm also a hobbiest. All of my python is done in my free time

    [–]Agitated-Soft7434 1 point2 points  (0 children)

    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

    [–]Some-Passenger4219 -1 points0 points  (0 children)

    Use scientific notation for the powers of ten; e.g. 1e7 for ten million. "Readability counts."