Stack Y: XSTR object
Stack X: a Number or LIST of Numbers
In the case where on the stack X register is a list (with numbers), the list is processed number by number from the head to tail.
The string will encrypted with the numbers one after the other
HINT: ASSIGN to CUSTOM: NEWLIST EXTEND form CATALOG/STR and XSTR from CATALOG/PRGM/
Your can use APPEND instead of EXTEND
On Newer Free42 (3.0.11) it is possible to append a number to a list with [+] key
Code: Select all
XSTR "TEXT"
2 SIN
XEQ "RndStr"
@DECRYPT
2 SIN
XEQ "RndStr"
Code: Select all
XSTR "TEXT"
NEWLIST
1 EXTEND 2 EXTEND 3 EXTEND
XEQ "RndStr"
@DECRYPT
NEWLIST
3 EXTEND 2 EXTEND 1 EXTEND
XEQ "RndStr"
Code: Select all
XSTR "TEXT"
1 XEQ "RndStr" 2 XEQ "RndStr" 3 XEQ "RndStr"
@Decrypt
3 XEQ "RndStr"
NEWLIST
2 APPEND 1 APPEND
XEQ "RndStr"
Code: Select all
00 { 85-Byte Prgm }
01▸LBL "RndStr"
02 LIST?
03 GTO B
@GTO A
@List of numbers as "Secret"
04▸LBL A
05 FUNC 21
06 SEED
07 DROP
08 NEWSTR
@MAIN LOOP
09▸LBL 00
10 HEAD ST Y
@ SKIP <=> GTO a LBL a
11 GTO a
12 RTN
13▸LBL a
14 XEQ C
15 EXTEND
16 GTO 00
@List of numbers as "Secret"
17▸LBL B
18 FUNC 21
19 X<>Y
20▸LBL 01
21 HEAD ST Y
@ SKIP <=> GTO a LBL a
22 GTO b
23 RTN
24▸LBL b
25 XEQ A
26 GTO 01
@CRYPT Char
27▸LBL C
28 FUNC 11
29 C→N
30 RAN
31 256
32 ×
33 XOR
34 N→C
35 RTN
36 END