added a TI-74 port
This commit is contained in:
@@ -139,6 +139,26 @@ implementation to be considered correct:
|
|||||||
4. The decryption part shall sanitize the ciphertext before processing,
|
4. The decryption part shall sanitize the ciphertext before processing,
|
||||||
removing any whitespace and non-letter characters from the input.
|
removing any whitespace and non-letter characters from the input.
|
||||||
|
|
||||||
|
TI-74 BASIC port
|
||||||
|
----------------
|
||||||
|
The [dracondi.b74](dracondi.b74) file in this repository contains a port of the
|
||||||
|
cipher to the Texas Instruments TI-74 handheld computer in its native BASIC
|
||||||
|
language dialect. This port has been developed and tested on the TI-74S model
|
||||||
|
and contains the following limitations:
|
||||||
|
|
||||||
|
1. The message length is restricted by the device's line limit.
|
||||||
|
2. No message prefiltering is done: enter the plaintext strictly in lowercase,
|
||||||
|
without any spaces and non-alphabetical characters.
|
||||||
|
3. The resulting ciphertext is divided with spaces every five characters but
|
||||||
|
the last group is not autofilled.
|
||||||
|
4. When decrypting, you can enter the ciphertext with spaces but no other non-
|
||||||
|
alphabetical characters are allowed.
|
||||||
|
5. No explicit exit command provided, use the BREAK key to exit the program.
|
||||||
|
|
||||||
|
For field operation, this port requires your keyphrases to be hardcoded in the
|
||||||
|
line 100 and 110 `DATA` statements. You can change the line numbers as long as
|
||||||
|
they remain the first `DATA` statements in the device's program memory.
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
-------
|
-------
|
||||||
Created by Luxferre in 2025, released into the public domain with no warranties.
|
Created by Luxferre in 2025, released into the public domain with no warranties.
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
100 DATA firstkeyphrase
|
||||||
|
110 DATA secondkeyphrase
|
||||||
|
120 PRINT "Initializing keys..."
|
||||||
|
130 RANDOMIZE
|
||||||
|
140 READ P1$,P2$
|
||||||
|
150 CALL KEYGEN(P1$,KA1$)
|
||||||
|
160 CALL KEYGEN(P2$,KA2$)
|
||||||
|
170 LINPUT "Operation (k/e/d): ";OP$
|
||||||
|
180 IF OP$="k" THEN 190 ELSE 220
|
||||||
|
190 PRINT "KA1: ";KA1$:PAUSE
|
||||||
|
200 PRINT "KA2: ";KA2$:PAUSE
|
||||||
|
210 GOTO 170
|
||||||
|
220 IF OP$="e" THEN 230 ELSE 270
|
||||||
|
230 LINPUT "Msg: ";MSG$:IF MSG$="" THEN 170
|
||||||
|
240 CALL DRENC(MSG$,KA1$,KA2$,RES$)
|
||||||
|
250 PRINT "Enc: ";RES$:PAUSE
|
||||||
|
260 GOTO 230
|
||||||
|
270 IF OP$="d" THEN 280 ELSE 170
|
||||||
|
280 LINPUT "Msg: ";MSG$:IF MSG$="" THEN 170
|
||||||
|
290 CALL DRDEC(MSG$,KA1$,KA2$,RES$)
|
||||||
|
300 PRINT "Dec: ";RES$:PAUSE
|
||||||
|
310 GOTO 280
|
||||||
|
320 SUB DRENC(M$,KA1$,KA2$,RES$)
|
||||||
|
330 OFFS=INT(26*RND)
|
||||||
|
340 RES$=SEG$(KA1$,OFFS+1,1)
|
||||||
|
350 L=LEN(M$):SK=1
|
||||||
|
360 FOR I=1 TO L
|
||||||
|
370 C$=SEG$(M$,I,1)
|
||||||
|
380 CI=POS(KA1$,C$,1)+OFFS
|
||||||
|
390 IF CI>26 THEN CI=CI-26
|
||||||
|
400 CT$=SEG$(KA1$,CI,1):RES$=RES$&CT$
|
||||||
|
410 SK=SK+1
|
||||||
|
420 IF SK=5 THEN 430 ELSE 440
|
||||||
|
430 SK=0:RES$=RES$&" "
|
||||||
|
440 OFFS=POS(KA2$,CT$,1)+I-1
|
||||||
|
450 IF OFFS>25 THEN OFFS=OFFS-26*INT(OFFS/26)
|
||||||
|
460 NEXT I
|
||||||
|
470 SUBEND
|
||||||
|
480 SUB DRDEC(M$,KA1$,KA2$,RES$)
|
||||||
|
490 OFFS=POS(KA1$,SEG$(M$,1,1),1)-1
|
||||||
|
500 M$=SEG$(M$,2,1024)
|
||||||
|
510 RES$="":L=LEN(M$):RI=0
|
||||||
|
520 FOR I=1 TO L
|
||||||
|
530 C$=SEG$(M$,I,1):IF C$=" " THEN 600
|
||||||
|
540 RI=RI+1
|
||||||
|
550 CI=POS(KA1$,C$,1)-OFFS
|
||||||
|
560 IF CI<1 THEN CI=CI+26
|
||||||
|
570 RES$=RES$&SEG$(KA1$,CI,1)
|
||||||
|
580 OFFS=POS(KA2$,C$,1)+RI-1
|
||||||
|
590 IF OFFS>25 THEN OFFS=OFFS-26*INT(OFFS/26)
|
||||||
|
600 NEXT I
|
||||||
|
610 SUBEND
|
||||||
|
620 SUB KEYGEN(P$,KA$)
|
||||||
|
630 KA$=""
|
||||||
|
640 L=LEN(P$)
|
||||||
|
650 FOR I=1 TO L
|
||||||
|
660 C$=SEG$(P$,I,1)
|
||||||
|
670 IF POS(KA$,C$,1)>0 THEN 680 ELSE 710
|
||||||
|
680 CK=ASC(C$)-72:IF CK>25 THEN CK=CK-26
|
||||||
|
690 C$=CHR$(97+CK)
|
||||||
|
700 GOTO 670
|
||||||
|
710 KA$=KA$&C$
|
||||||
|
720 NEXT I
|
||||||
|
730 KA$=KA$&"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
740 KR$="":L2=LEN(KA$)
|
||||||
|
750 FOR I=1 TO L2
|
||||||
|
760 C$=SEG$(KA$,I,1)
|
||||||
|
770 IF POS(KR$,C$,1)=0 THEN KR$=KR$&C$
|
||||||
|
780 NEXT I
|
||||||
|
790 L=L-INT(L/26)*26
|
||||||
|
800 KA$=SEG$(KR$,L+1,26)&SEG$(KR$,1,L)
|
||||||
|
810 SUBEND
|
||||||
|
820 END
|
||||||
Reference in New Issue
Block a user