I have some code that in mathematica that decrypts a RSA cryptation. I would like to make a function RSACrack[n,e, crypto] so that I sort of just bake in the code into that function and get a return value from it. How do I do this with mathematica? I attached the code I would like to “abstract(?)” into a simple function line.
Please let me know if it’s unclear what I seek! Thanks in advance.
Perhaps the best way to help you along your way with this is to point you to this tutorial:
And here is a tutorial on defining functions:
as well as two links that talk about how to localize variables:
and
Once you have this under your belt you will be in a position to take the set of computations that are in your notebook, place them in a module to localize those variables that should not be exposed, and then create a function definition for those parameters that you want to supply as arguments to your function.
I solved my problem! It was pretty simple in the end, what I was seeking was something like
RSACrack[n_, e_, crypto_] :=Module[{} ]
And then I basically just threw my old code in there with some minor adjustments to make the code all dynamic/automatic.
Great!
The main thing to watch out for is being sure that all parameters that should be localized in the Module are included in the list of the first argument so that nothing leaks out.