Last active
February 28, 2024 23:39
-
-
Save artificialstarlight/02de167e8daacc8688cb0a33356219c3 to your computer and use it in GitHub Desktop.
This is an implementation of a very simple version of RSA in TI-BASIC.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//remember to not type comments when typing the code into your calculator! | |
//This program is an implementation of the RSA algorithm, using small prime numbers, in TI-BASIC. | |
ClrHome | |
{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}->L1 | |
Prompt X | |
Lbl A | |
randInt(1,25)->T | |
randInt(1,25)->W | |
L1(T)->P | |
L1(W)->Q | |
If P*Q<X | |
Goto A | |
P*Q->N | |
2->E | |
Disp "PUBLIC KEY:" | |
Disp N,E | |
(P-1)*(Q-1)->θ | |
While E<θ | |
gcd(E,θ)->C | |
If C=1 | |
Then | |
Goto 1 | |
Else | |
E+1->E | |
End | |
End | |
Lbl 1 | |
2->K | |
While(1+(K*θ))/E≠int((1+(K*θ))/E) | |
K+1->K | |
End | |
(1+(K*θ))/E->D | |
X^E->C | |
C-N*int(C/N)->V | |
1->J | |
For(I,1,D) | |
V*J->J | |
J-N*int(J/N)->J | |
End | |
Output(1,1,"MSG DATA" | |
Output(2,10,X | |
Output(3,1,"ENCRYPTED DATA" | |
Output(4,10,V | |
Output(5,1,"ORIG. MSG" | |
Output(6,10,J |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is giving me a syntax error for some reason. I copy and pasted it perfectly in