Given two prime number character strings (p and q), generate the RSA public and private keys (n and d) with e = 65537. The more difficult part is doing this without the use of symbolic numbers. Example: p = '3355335697481001330501721', q = '5955344080483688912855719' n='19982178584029090861856118769095354822153154192399' d='3270348772331599380262578849367006078599068947553'
Solution Stats
Problem Comments
7 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers20
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15826 Solvers
-
Find state names that start with the letter N
1516 Solvers
-
6722 Solvers
-
2093 Solvers
-
Unique values without using UNIQUE function
459 Solvers
More from this Author65
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I get different results for d in test cases 2, 3, and 4 (in particular, d=929660805638728623653 for test case 2).
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.
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?
@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.
Before I made my entry a few minutes ago, the smallest non-cheat solution was Tim's at 80. My second solution doesn't even include using the minor "ans=" cheat.