I get different results for d in test cases 2, 3, and 4 (in particular, d=929660805638728623653 for test case 2).
This was my first Cody problem and I had a mistake in the assert within the test cases. I fixed the problem. Previously the assert was looking for [n,d] combined into a single character array. I have tested the test cases and they are correct. You should use the Euclidean algorithm.
If I understand correctly, we should have mod(d*e,phi)=1, where phi=(p-1)*(q-1). My answers seem to satisfy that condition, but test cases 2, 3, and 4 do not.
Tim, you are absolutely correct. Thanks for the comment. I fixed the test cases.
Could someone help me out with the modular inversion. I can't seem to get it to work for any large numbers. I've been stuck for a while
I think my main issue is that I cannot use the mod function with large numbers, what is a way around this?
look at importing java biginteger
@David Hill. Thanks, that worked a lot better for me
One should first consider if MATLAB is even adapted for these kinds of calculations. Still, I had a lot of fun.
Googling can supplant programming sometimes.
Right and wrong
Replicate elements in vectors
Golomb's self-describing sequence (based on Euler 341)
Flip the vector from right to left
Montgomery Reduction Algorithm (REDC)
All flights lead to Idaho Falls
Mask Generation Function (MGF1) for PKCS #1 Standard utilizing Optimal Asymmetric Encryption Padding for RSA Cryptography
Binary Array to Hex Representation
Create State Array for initiating SHA-3-224 Hash
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office