parse version name level date1 date2 date3; parse source TOS ZED; CALL DETOS ;
PARSE ARG V ;
IF TRANSLATE(V) == "DTEST" THEN DO; CALL DTEST; EXIT; END
V = "-E -H -FI C:\U\CODE\REXX\KT.REX -FO ZZ1.TXT -psbr 0 -psb 4 -dcf -P Picco is my very pretty smart friend"
CALL GARGS; PULL Z
V = "-D -H -FI C:\U\CODE\REXX\ZZ1.TXT -FO ZZ2.TXT -psbr 0 -psb 4 -dcf -P Picco is my very pretty smart friend"
CALL GARGS; SAY "It Worked ...";PULL Z; EXIT
CALL DTEST
SAY; SAY "Press ENTER to exit program";PULL Z
EXIT
GARGS:
UV = TRANSLATE(V) ;
PW = "";WP = WORDPOS("-P",UV,1); IF WP > 0 THEN PW = SUBWORD(V,(WP+1));ELSE CALL DERR ;
PSBR = 0;WP = WORDPOS("-PSBR",UV,1); IF WP > 0 THEN PSBR = SUBWORD(V,(WP+1),1) ;
SB = 3; WP = WORDPOS("-PSB",UV,1); IF WP > 0 THEN SB = SUBWORD(V,(WP+1),1) ;
CALL PPASS
FIN = "";WP = WORDPOS("-FI",UV,1); IF WP > 0 THEN FIN = SUBWORD(V,(WP+1),1);ELSE CALL DERR ;
FOUT = "";WP = WORDPOS("-FO",UV,1); IF WP > 0 THEN FOUT = SUBWORD(V,(WP+1),1); ELSE CALL DERR ;
FOUT = PTH||FOUT; IF SL = "\" THEN 'DEL 'FOUT;IF SL = "/" THEN 'rm 'FOUT ;
ECODE = 0; IF WORDPOS("-E",UV,1) > 0 THEN ECODE = 1 ;
DCODE = 0; IF WORDPOS("-D",UV,1) > 0 THEN DCODE = 1 ;
HF = 0;IF WORDPOS("-H",UV,1) > 0 THEN HF = 1 ;
WP = WORDPOS("-SBR",UV,1); IF WP > 0 THEN CALL BTABLE SUBWORD(V,(WP+1),1);ELSE CALL BTABLE NPW;
WP = WORDPOS("-SB",UV,1); IF WP > 0 THEN SB = SUBWORD(V,(WP+1),1); ELSE SB = 3 ;
WP = WORDPOS("-DCF",UV,1); IF WP > 0 THEN DCF = 1;ELSE DCF = 0 ;
IF ECODE THEN CALL FBENCODE FIN,FOUT ;
IF DCODE THEN CALL FBDECODE FIN,FOUT ;
IF DCF = 1 THEN DO
IF SL = "\" THEN DO; 'START NOTEPAD 'FIN; 'START NOTEPAD 'FOUT; END ;
IF SL = "/" THEN DO; 'geany 'FIN; 'geany 'FOUT; END ;
END
RETURN
DETOS:
SL = "/";IF TRANSLATE(LEFT(TOS,3)) == "WIN" THEN SL = "\" ;
T = WORD(ZED,2); LP = LASTPOS(SL,T); PTH = LEFT(T,LP); NUMERIC DIGITS 20 ;
RETURN
PPASS: ;
CALL BTABLE PSBR ;
PP = CRC32(PW); T = TRANSLATE(TRANSLATE(PW" "PP)," ","AEIOU"); NPW = WORDS(T) ;
PPP = 0; EP = ENCODE(PW);PP = EP; CALL BTABLE NPW ;
RETURN
FBDECODE: PROCEDURE EXPOSE HF DCF PP PPP SB TSB ML L. ; PARSE ARG FIN,FOUT ;
FL = CHARS(FIN); TR = CHARIN(FIN,1,0); TR = CHAROUT(FOUT,,1) ;
CI = 1;IF HF THEN CI = 2
DO CNT = 1 TO FL BY CI ;
ET = ""; ET = CHARIN(FIN,CNT,CI);IF HF THEN ET = X2C(ET) ;
PT = ""; PT = DECODE(ET) ;
XR = ""; XR = UTRAN(PT) ;
TR = CHAROUT(FOUT,XR); IF DCF THEN DO;CALL ASAY 19,44,9,XR;END;
END CNT; TR = LINEOUT(FIN); TR = LINEOUT(FOUT) ;
RETURN 1
FBENCODE: PROCEDURE EXPOSE HF DCF PP PPP SB TSB ML L. ; PARSE ARG FIN,FOUT ;
FL = CHARS(FIN); TR = CHARIN(FIN,1,0); TR = CHAROUT(FOUT,,1) ;
DO FL ;
PT = ""; PT = CHARIN(FIN,,1) ;
XR = ""; XR = TRANS(PT) ;
ET = ""; ET = ENCODE(XR); IF DCF THEN DO;CALL ASAY 19,40,12,PT;CALL ASAY 19,42,15,ET;END;
IF HF THEN TR = CHAROUT(FOUT,C2X(ET));ELSE TR = CHAROUT(FOUT,ET) ;
END; TR = LINEOUT(FIN); TR = LINEOUT(FOUT) ;
RETURN 1
FSENCODE: PROCEDURE EXPOSE DCF PP PPP SB TSB ML L. ; PARSE ARG FIN,FOUT ;
DO WHILE LINES(FIN) > 0 ;
PT = ""; PT = TRANS(LINEIN(FIN)); IF LEFT(PT,1) == D2C(26) THEN LEAVE ;
ET = ""; ET = ENCODE(PT) ;
TR = LINEOUT(FOUT,ET); IF DCF THEN DO; CALL ASAY 11,1,12,PT; CALL ASAY 12,1,15,ET; END ;
END; TR = LINEOUT(FIN); TR = LINEOUT(FOUT) ;
RETURN 1
FSDECODE: PROCEDURE EXPOSE DCF PP PPP SB TSB ML L. ; PARSE ARG FIN,FOUT ;
DO WHILE LINES(FIN) > 0 ;
ET = ""; ET= LINEIN(FIN) ;
OP = ""; OP = DECODE(ET) ;
PT = ""; PT = UTRAN(OP) ;
TR = LINEOUT(FOUT,PT); IF DCF THEN DO;CALL ASAY 15,1,9,PT;END;
END; TR = LINEOUT(FIN); TR = LINEOUT(FOUT) ;
RETURN 1
ENCODE: PROCEDURE EXPOSE PP PPP SB TSB ML L. ; PARSE ARG PT ;
LPT = LENGTH(PT); LPP = LENGTH(PP); ET = "" ;
DO CNT = 1 TO LPT ;
P = 0; Q = 0; C = 0; N = 0 ;
SB = INCSB(SB,TSB) ;
P = FINDP(SUBSTR(PT,CNT,1),SB) ;
PPP = INCPP(PPP,LPP) ;
Q = FINDP(SUBSTR(PP,PPP,1),SB) ;
C = P + Q; IF C >=ML THEN C = C -ML ;
N = C + 1 ;
ET = ET || WORD(L.N,1) ;
END CNT
RETURN (ET)
DECODE: PROCEDURE EXPOSE PP PPP SB TSB ML L. ; PARSE ARG ET ;
LET = LENGTH(ET); LPP = LENGTH(PP); OP = "" ;
DO CNT = 1 TO LET ;
C = 0; K = 0; M = 0 ;
SB = INCSB(SB,TSB) ;
C = FINDL(SUBSTR(ET,CNT,1)) ;
PPP = INCPP(PPP,LPP) ;
K = FINDP(SUBSTR(PP,PPP,1,),SB) ;
M = C - K; IF M < 0 THEN DO; M = SUBSTR(M,2); M = ML - M; END ;
A = FINDA(M,SB) ;
OP = OP || A ;
END CNT
RETURN (OP)
DERR: SAY "ERROR INVALID PARM"; SAY V; PULL Z; EXIT; RETURN
INCPP: PROCEDURE; PARSE ARG PPP,LPP; PPP = PPP + 1; IF PPP > LPP THEN PPP = 1; RETURN (PPP)
INCSB: PROCEDURE; PARSE ARG SB,TSB; SB = SB + 1; IF SB > TSB THEN SB = 1; RETURN (SB)
FINDP: PARSE ARG PC,SB; DO PCNT = 1 TO ML; W = WORD(L.PCNT,(SB+1)); IF LEFT(W,1) == PC THEN RETURN SUBSTR(W,3); END; RETURN (999999)
FINDC: PARSE ARG N; RETURN WORD(L.N,1)
FINDL: PARSE ARG L; T = ""; DO LCNT = 1 TO ML; IF L == WORD(L.LCNT,1) THEN T = SUBSTR(WORD(L.LCNT,2),3); END; RETURN (T)
FINDA: PARSE ARG M,SB; DO ACNT = 1 TO ML; N = SUBSTR(WORD(L.ACNT,SB+1),3); IF N == M THEN RETURN (LEFT(WORD(L.ACNT,SB+1),1)); END; RETURN ("ZZZ")
TRANS: PROCEDURE; PARSE ARG X; RETURN (TRANSLATE(X,D2C(232)D2C(213)D2C(210)D2C(226),X2C(20)X2C(0D)X2C(0A)X2C(1A)))
UTRAN: PROCEDURE; PARSE ARG X; RETURN (TRANSLATE(X,X2C(20)X2C(0D)X2C(0A)X2C(20),D2C(232)D2C(213)D2C(210)D2C(226)))
BTABLE: ARG N
IF N == 0 THEN
SBS = "ABCDE1FGHI2JKL3MNO4PQR5STU6VWX7YZ!@#$%^&*()_-+={[}]|\:;<,>.?/~`abc8defg9hijk0lmnopqrstuvwxyz"||D2C(232)||X2C(27)||X2C(22)||D2C(210)||D2C(213)||D2C(226)
ELSE DO
RNA = RRSBS(N); SBS= ""
DO CNT = 1 TO WORDS(RNA);SBS = SBS||SUBSTR(ABC,WORD(RNA,CNT),1);END
SBS = SBS||D2C(232)||X2C(27)||X2C(22)||D2C(210)||D2C(213)||D2C(226)
END
ABC = "ZYXWVUTSRQPONMLKJIHGFEDCBA0123456789zyxwvutsrqponmlkjihgfedcba!@#$%^&*()_-+={[}]|\:;<,>.?/`~"||X2C(22)||X2C(27)||D2C(232)||D2C(213)||D2C(210)||D2C(226)
ML = LENGTH(ABC); TSB = ML;
DO CNT = 1 TO ML; L.CNT = SUBSTR(ABC,CNT,1)" "SUBSTR(SBS,CNT,1)"="SUBSTR((CNT-1),1,2," "); END
DO SB = 2 TO ML
N = WORDS(L.1); TL = ML + 1; L.TL = L.1" " LEFT(WORD(L.1,N),1)"="SUBSTR((ML-1),1,2," ")
DO CNT = 1 TO ML; TN = CNT + 1; L.CNT = L.CNT" "LEFT(WORD(L.TN,N),1)"="SUBSTR((CNT-1),1,2," "); END
END
RETURN
RRSBS: PROCEDURE; ARG N;
Y.1 = "18 47 12 52 90 46 20 51 14 70 19 34 76 78 75 81 28 73 38 64 61 60 50 11 42 25 30 71 17 69 91 41 63 74 85 13 36 82 88 53 86 65 7 9 35 77 8 59 16 89 40 33 67 6 15 1 22 2 4 80 79 66 68 29 55 44 72 26 5 45 83 24 43 27 3 54 92 10 23 56 48 57 31 37 62 21 84 39 58 32 49 87 "
Y.2 = " 6 33 69 34 28 44 2 85 81 22 48 47 64 15 67 83 41 42 62 63 19 13 77 27 29 74 46 10 66 30 89 11 53 14 40 26 91 78 7 92 55 52 61 8 80 23 59 39 90 1 79 57 51 72 5 17 58 50 86 70 16 36 49 3 32 43 37 31 75 12 9 68 87 65 84 45 24 35 25 18 4 76 73 56 88 21 82 60 54 71 38 20 "
Y.3 = " 4 55 46 24 77 41 61 8 91 50 90 19 68 53 6 23 70 29 75 47 73 16 10 80 81 12 49 64 62 18 36 15 2 25 14 44 72 31 78 28 30 20 3 9 56 65 86 32 89 26 76 43 59 54 84 42 57 27 87 60 34 74 5 52 58 39 17 11 7 37 45 38 40 35 63 79 71 66 21 92 51 33 48 13 1 67 83 88 82 22 85 69 "
Y.4 = "78 76 70 74 30 43 47 56 65 81 52 33 86 62 11 4 37 6 54 1 83 89 51 90 40 58 79 88 48 66 73 63 14 25 5 28 87 39 16 8 23 21 45 55 15 20 91 32 53 17 27 59 22 36 7 68 31 41 61 2 18 42 85 44 3 49 24 34 71 64 60 29 13 84 82 50 77 67 12 9 75 72 19 69 10 35 26 46 38 92 80 57 "
Y.5 = "87 36 47 37 54 4 66 22 77 55 64 61 15 68 76 1 67 74 12 46 26 24 84 62 91 72 17 7 50 39 63 65 35 27 25 2 33 71 80 34 81 23 38 8 86 21 73 29 10 60 45 30 14 11 5 16 40 69 79 85 42 32 9 78 59 18 89 3 13 82 70 6 19 31 58 53 20 44 57 51 49 56 90 83 43 75 28 88 48 41 52 92 "
Y.6 = "16 8 79 2 73 60 27 66 67 37 12 34 85 86 75 45 21 70 71 11 30 55 57 72 17 69 36 47 3 76 80 7 26 58 54 82 64 44 74 68 20 14 4 35 41 65 83 13 61 84 56 39 78 62 90 46 15 1 88 53 42 18 77 28 91 40 59 52 89 10 63 50 32 51 22 49 43 5 81 9 29 48 87 23 6 38 92 33 31 25 19 24 "
Y.7 = " 9 45 69 21 91 13 40 88 74 7 53 81 22 89 92 36 23 57 83 70 72 90 2 84 29 56 15 55 14 19 71 25 4 67 75 79 35 11 87 64 18 48 8 58 61 27 28 6 85 20 47 3 62 59 82 26 30 63 5 42 31 32 54 66 37 80 41 52 60 50 86 24 34 44 39 43 46 16 17 76 65 68 10 12 49 1 33 73 38 51 77 78 "
Y.8 = "65 16 78 39 14 2 63 28 89 41 42 50 85 5 84 30 52 34 8 61 67 10 72 54 73 69 59 25 36 86 90 76 66 80 88 55 19 48 74 27 31 60 43 21 17 23 83 51 13 92 4 45 64 53 3 57 46 6 11 70 37 49 71 40 29 87 7 58 24 75 47 81 77 38 26 22 18 12 1 32 20 9 68 79 15 82 56 33 44 35 62 91 "
Y.9 = "46 1 37 17 23 83 25 21 65 14 87 39 77 3 47 71 72 10 22 42 92 70 56 18 15 54 40 69 82 45 81 64 31 68 85 19 74 79 6 84 80 24 38 16 5 50 73 11 86 4 91 7 60 78 55 63 28 89 49 8 13 61 66 26 62 52 27 30 58 41 43 2 33 59 51 67 88 48 53 44 90 57 12 20 35 34 9 32 36 76 29 75 "
Y.10 = "14 68 78 61 79 16 86 18 65 60 70 66 43 47 8 28 83 59 58 67 82 29 69 38 10 50 6 21 3 11 42 1 24 2 33 87 30 25 77 57 35 26 84 92 80 40 54 88 20 31 13 44 39 27 71 64 51 49 55 4 41 81 76 37 89 19 90 34 56 23 12 75 53 22 48 5 36 74 45 46 72 62 85 7 52 32 63 73 17 15 91 9 "
Y.11 = "90 7 16 66 4 37 10 65 41 23 57 33 75 54 27 76 85 14 59 77 26 6 1 46 13 11 44 5 30 45 8 31 84 32 48 22 53 64 82 21 39 71 78 74 91 51 28 9 12 2 70 81 73 34 83 61 80 89 55 87 19 88 47 42 25 18 92 86 3 58 38 49 40 72 52 15 62 43 17 63 24 29 67 35 68 69 36 20 50 56 79 60 "
Y.12 = "35 31 21 69 11 91 52 60 56 54 46 86 38 37 25 34 3 13 39 42 76 51 29 68 26 16 87 81 24 89 32 36 4 48 19 12 70 47 1 18 67 65 59 75 74 79 85 72 64 90 30 55 33 66 62 7 45 82 9 88 83 73 53 50 14 27 22 2 41 49 17 78 80 63 10 20 44 23 71 77 15 8 5 43 61 57 84 92 6 40 58 28 "
Y.13 = " 9 26 19 81 44 62 13 58 25 91 41 56 66 48 42 27 2 63 22 18 43 1 85 88 86 67 6 51 75 55 52 82 68 31 69 79 32 76 30 12 64 45 46 23 33 36 61 11 29 92 87 35 47 17 57 37 59 65 72 60 16 71 10 24 3 40 53 38 14 89 34 80 74 5 77 39 15 28 84 73 8 54 90 20 21 4 50 7 70 49 78 83 "
Y.14 = "77 45 84 50 49 37 79 23 66 82 4 60 68 57 47 6 15 12 10 13 18 16 59 28 35 74 90 31 34 61 85 21 75 62 67 19 32 7 58 72 27 65 92 14 20 43 40 11 41 39 30 71 25 86 87 88 56 33 2 22 48 63 80 3 64 91 73 76 38 55 53 24 46 89 36 17 8 5 51 29 26 42 1 44 9 78 81 54 70 52 83 69 "
Y.15 = "60 27 5 55 86 49 31 75 10 4 91 26 78 19 36 14 71 79 81 72 12 41 57 50 39 76 38 66 83 45 42 87 28 23 52 33 44 1 29 9 62 85 80 70 63 48 34 82 20 53 90 18 43 37 67 24 77 59 25 22 46 64 35 69 15 84 11 16 89 17 8 56 54 73 51 47 58 68 30 6 3 88 13 32 21 65 2 7 61 40 92 74 "
Y.16 = "62 63 33 17 4 22 43 10 34 12 81 28 71 87 83 11 50 27 69 74 38 56 14 21 84 2 25 59 8 82 6 15 48 76 61 66 16 5 80 68 30 77 58 73 60 89 75 39 3 19 1 72 44 31 53 51 90 23 9 88 57 41 24 91 7 79 32 36 92 54 26 20 52 47 13 18 85 70 64 55 46 37 35 78 67 49 65 86 42 45 40 29 "
Y.17 = " 2 41 46 77 13 84 64 81 45 58 29 42 11 65 85 72 3 18 37 89 92 53 33 54 80 67 25 16 62 74 69 88 91 23 79 44 86 8 66 59 61 2 43 28 14 82 9 38 27 50 63 24 56 1 5 76 34 68 22 90 73 32 70 52 49 19 21 26 6 83 39 75 55 60 35 40 51 15 17 7 20 47 87 4 36 57 30 31 48 78 71 10 "
Y.18 = "17 64 74 33 29 23 42 1 56 59 85 57 35 38 91 16 86 55 34 73 60 32 41 58 53 75 11 28 44 4 39 6 87 62 22 82 15 10 61 9 52 2 7 89 66 78 54 70 71 80 65 69 46 51 19 24 49 18 63 31 47 50 36 40 68 25 27 13 81 20 5 76 77 83 92 79 84 67 12 21 45 26 43 37 8 3 90 30 48 72 88 14 "
Y.19 = "30 78 11 77 22 92 83 60 12 56 75 53 42 72 50 1 52 15 26 16 69 36 24 38 87 32 74 18 80 39 81 35 73 58 19 10 90 34 14 47 57 89 68 59 49 8 88 21 43 91 29 76 64 27 82 51 25 37 46 79 28 45 4 48 71 44 62 3 20 66 2 31 33 67 7 86 23 41 70 9 54 85 55 84 6 40 13 63 17 5 61 65 "
Y.20 = "67 42 27 7 46 2 51 53 23 9 79 64 10 34 85 88 59 26 6 19 58 11 91 72 81 71 48 17 1 41 12 82 73 61 68 87 33 38 16 24 57 15 70 86 8 54 65 50 52 90 55 89 78 22 40 32 43 76 92 5 44 49 25 84 77 75 29 20 83 4 35 45 14 47 37 28 74 18 80 3 36 31 63 66 56 21 30 60 69 39 62 13 "
Y.21 = "53 30 70 12 9 17 91 49 47 87 81 31 62 61 86 77 24 74 67 72 82 71 66 16 46 44 85 21 56 43 63 60 20 75 64 18 88 92 83 32 8 39 69 23 54 41 3 76 26 50 52 42 15 38 36 34 68 89 33 58 19 2 6 78 51 37 11 40 27 29 13 90 7 79 35 25 28 5 55 84 59 10 14 57 1 45 4 65 73 48 80 22 "
Y.22 = " 8 33 57 69 27 61 83 26 41 35 25 22 75 67 30 34 82 54 13 2 52 15 72 74 12 14 70 91 76 1 53 58 51 92 49 66 78 36 10 9 20 39 45 19 42 43 80 88 46 50 56 4 11 37 16 87 68 48 79 90 32 81 59 55 44 24 89 86 85 23 17 5 73 3 6 60 77 29 18 71 64 21 65 31 84 40 47 7 28 38 63 62 "
Y.23 = "64 2 35 52 40 72 89 4 20 76 70 80 58 15 5 86 39 44 66 37 60 38 51 25 55 48 3 53 17 32 71 43 24 45 91 21 12 14 47 92 42 46 61 13 81 27 19 75 22 16 10 88 1 62 30 33 41 85 68 73 50 82 54 9 29 18 8 79 49 74 57 28 78 59 67 31 11 6 77 65 26 83 90 87 34 84 36 56 69 7 23 63 "
Y.24 = "44 33 34 23 53 68 81 62 87 70 58 88 92 1 52 45 24 29 63 49 2 6 25 51 60 31 9 17 71 64 84 32 76 59 12 18 78 27 41 13 21 69 11 79 47 61 72 39 83 89 50 48 55 65 77 91 82 35 74 10 40 86 42 37 16 43 66 80 90 75 5 38 36 28 14 3 56 22 67 19 54 57 8 4 26 20 30 73 85 15 46 7 "
Y.25 = "89 24 76 58 44 59 23 65 60 68 32 77 27 63 43 49 48 91 26 55 37 54 31 52 74 41 38 9 42 7 1 11 30 10 28 40 56 92 70 66 45 12 21 72 69 13 22 33 2 57 36 81 90 79 64 86 5 4 17 6 20 46 34 15 84 85 87 71 80 25 35 61 73 16 75 47 19 29 78 62 82 14 83 53 39 18 3 88 67 50 51 8 "
Y.26 = "13 2 10 22 44 76 38 1 75 51 88 92 16 86 31 46 74 66 65 63 12 61 45 72 43 58 40 82 85 47 8 69 5 56 87 71 91 83 89 27 50 48 84 79 7 53 14 36 57 59 80 55 60 41 78 34 11 30 24 35 20 90 19 70 23 26 3 81 37 77 39 28 52 29 68 32 42 64 9 33 67 73 4 6 49 21 17 54 18 15 25 62 "
Y.27 = "53 23 37 71 46 54 31 55 21 86 62 91 45 85 11 66 13 26 81 1 43 14 58 88 38 50 79 41 2 65 90 73 51 9 74 8 25 30 18 4 7 48 67 17 82 60 22 59 10 63 92 32 49 56 80 28 34 40 84 35 6 24 33 19 68 12 89 39 77 42 27 57 16 72 76 69 44 83 70 47 61 29 64 36 87 15 78 3 52 20 5 75 "
Y.28 = "46 68 27 79 9 4 76 88 48 23 5 82 38 21 44 20 11 51 72 8 24 43 17 90 55 14 35 69 87 70 92 61 42 6 65 86 81 75 26 31 74 63 18 89 2 80 47 15 34 36 32 49 85 13 52 39 28 45 3 29 19 78 67 30 56 7 53 37 40 66 25 10 50 91 71 57 84 22 54 60 12 33 83 73 64 16 58 1 41 62 59 77 "
Y.29 = "23 34 36 70 83 54 51 92 78 31 41 62 25 63 58 8 40 65 6 19 90 72 61 74 43 53 79 11 35 5 91 24 27 29 16 60 85 84 9 50 39 68 12 48 86 82 10 57 44 89 2 71 13 77 67 66 55 88 69 49 21 3 20 80 56 4 73 75 32 76 33 38 18 42 17 59 64 87 28 22 30 52 26 15 37 7 47 14 81 45 46 1 "
Y.30 = "31 67 51 21 36 68 52 57 77 55 48 23 12 41 90 15 11 39 40 20 60 85 16 65 64 82 81 79 54 25 53 61 8 74 59 3 6 75 35 62 87 18 9 43 89 22 66 71 45 47 14 50 33 4 24 86 29 73 38 58 37 27 2 91 83 1 13 70 80 34 32 5 69 56 72 63 92 7 30 78 26 17 44 10 88 28 76 49 46 19 84 42 "
Y.31 = "13 87 65 21 62 20 60 81 86 4 49 12 54 14 55 5 66 89 11 10 15 90 52 48 23 27 24 68 44 80 75 72 1 82 31 6 2 18 47 63 84 83 36 8 46 39 35 30 32 58 22 85 26 7 64 70 38 9 71 29 43 67 59 56 78 28 92 34 40 3 51 53 74 73 33 19 79 45 16 69 57 25 61 37 41 77 88 17 42 91 50 76 "
Y.32 = "88 31 29 86 53 74 32 47 51 42 89 4 37 77 78 67 19 41 26 76 71 61 75 60 6 81 28 22 85 66 54 52 62 10 68 30 20 70 18 39 33 5 15 92 59 49 34 57 55 65 64 69 21 16 11 83 12 43 87 24 84 63 13 36 50 3 25 38 73 23 46 82 56 8 45 9 1 80 44 58 48 35 27 79 90 40 91 72 2 7 17 14 "
Y.33 = "62 53 26 78 48 72 80 13 21 25 2 88 87 68 65 23 5 71 61 81 42 22 20 4 6 75 66 43 30 86 7 29 16 15 52 17 11 41 40 38 91 79 19 63 51 31 77 28 54 74 45 32 73 70 67 76 8 83 27 39 69 49 64 1 9 84 35 24 89 10 36 46 90 57 18 33 37 50 55 47 34 58 82 14 92 56 12 44 85 60 59 3 "
Y.34 = "65 57 67 18 85 58 27 30 15 21 6 24 28 16 12 23 49 66 45 39 52 47 41 92 79 5 61 81 51 13 36 33 35 59 54 73 9 17 76 4 82 19 62 31 38 50 88 56 80 69 46 8 40 91 7 14 11 77 20 34 2 26 70 74 72 63 25 10 29 83 37 22 75 71 87 86 64 90 32 53 68 1 3 44 60 42 78 89 55 84 48 43 "
Y.35 = "68 38 81 45 73 82 67 44 37 25 47 36 15 12 92 63 16 69 18 57 90 71 88 70 23 31 50 22 76 46 10 48 79 53 51 13 24 72 14 66 11 32 5 64 42 75 54 86 7 89 20 56 84 21 65 8 87 3 85 52 41 77 83 40 80 60 2 30 29 43 6 74 61 26 35 9 49 59 33 78 27 1 55 19 28 39 58 17 34 62 91 4 "
Y.36 = "40 56 79 19 37 72 78 3 6 20 90 44 64 46 87 82 10 65 63 62 31 49 8 50 28 24 54 55 88 38 27 7 59 1 85 48 66 18 89 22 75 47 25 92 68 41 21 33 15 34 30 16 11 23 73 4 43 14 35 58 74 76 32 53 81 17 67 61 5 29 69 26 86 52 77 51 45 60 83 80 39 13 9 12 57 84 91 71 36 70 42 2 "
Y.37 = "20 16 24 65 47 13 34 52 69 73 31 23 56 71 39 12 1 54 25 51 46 5 48 83 67 90 4 32 60 2 57 79 8 15 85 3 70 84 9 80 61 87 35 17 42 11 72 26 86 82 92 21 63 58 53 30 88 7 66 91 50 76 77 10 33 18 59 64 41 49 14 38 44 43 45 29 89 6 78 40 19 37 36 81 55 74 22 28 27 75 68 62 "
Y.38 = "52 62 39 79 61 41 81 49 56 30 11 48 5 59 21 55 38 65 34 87 72 66 44 67 15 85 12 2 45 82 31 35 10 17 37 90 74 36 83 24 86 84 76 64 43 3 14 58 13 50 6 16 57 46 73 29 18 75 4 80 88 71 70 9 19 20 33 42 28 1 32 78 54 8 68 7 63 25 60 77 53 22 92 69 47 23 40 89 26 51 91 27 "
Y.39 = "30 61 53 84 24 3 72 86 43 14 74 73 89 7 39 47 90 15 19 78 11 63 17 75 87 26 77 10 6 64 27 23 51 31 40 36 20 44 82 5 55 21 32 33 2 8 56 9 16 52 69 37 79 41 58 1 45 50 62 71 13 60 38 57 25 18 35 88 70 81 28 12 34 42 54 85 65 22 91 49 68 66 67 76 83 4 48 92 59 46 80 29 "
Y.40 = "73 87 38 36 82 60 7 6 53 78 28 1 30 57 88 92 8 61 45 77 37 33 9 20 89 27 76 56 79 17 24 80 29 13 69 68 40 63 74 47 32 42 15 70 12 21 43 41 26 34 75 46 83 65 64 35 59 19 11 5 44 25 58 86 62 91 90 3 49 4 2 50 54 84 14 31 72 18 48 52 22 66 81 67 23 51 39 10 55 71 16 85 "
Y.41 = " 1 83 70 45 33 47 91 71 44 62 55 51 76 43 37 60 42 11 13 86 17 25 78 89 8 61 84 80 29 72 77 31 58 64 88 49 14 52 50 32 85 67 20 53 6 15 65 19 39 82 5 28 2 48 35 34 46 22 30 4 73 56 81 12 63 90 3 92 75 27 79 9 69 87 38 57 41 16 24 21 26 18 74 36 7 23 10 66 68 54 59 40 "
Y.42 = "50 22 47 66 89 60 90 39 86 71 64 12 32 57 2 65 45 9 49 84 77 63 68 26 56 70 82 76 85 92 17 20 62 48 88 25 21 46 36 51 1 6 38 83 78 30 44 29 75 28 8 19 73 91 37 10 61 4 42 80 81 43 41 14 18 13 52 27 54 55 23 67 79 16 11 7 33 31 34 69 74 59 58 87 15 53 40 35 72 3 24 5 "
Y.43 = "56 91 90 81 65 37 77 11 7 49 26 46 89 92 44 64 68 9 18 75 58 69 8 1 62 73 31 14 80 66 61 16 40 22 41 84 74 5 10 27 24 72 82 57 39 32 63 4 51 35 21 59 6 47 28 76 25 29 3 88 70 52 53 87 12 85 71 55 38 15 79 86 13 17 33 60 20 34 54 30 48 83 45 42 36 2 50 78 23 19 67 43 "
Y.44 = " 2 30 80 50 14 39 27 56 77 71 92 40 43 75 58 91 76 51 86 68 28 41 59 48 64 12 5 25 90 66 85 1 83 9 81 8 45 82 74 67 16 17 6 22 18 54 20 44 62 55 38 10 70 53 42 13 4 69 72 21 26 47 87 3 52 49 24 60 29 84 34 65 73 33 89 37 57 46 15 61 19 88 36 32 78 23 31 63 7 11 79 35 "
Y.45 = "88 23 84 90 47 13 4 89 37 12 74 43 76 69 70 85 66 48 2 65 42 57 59 21 81 91 73 38 7 1 30 79 44 61 11 31 55 60 68 86 63 72 82 10 8 77 25 40 19 17 53 3 34 78 24 26 50 22 41 49 45 46 9 29 39 75 64 36 20 18 28 71 35 51 54 80 83 15 14 92 56 32 52 16 33 5 67 6 58 87 62 27 "
Y.46 = "78 81 68 32 9 31 23 63 53 14 2 51 17 83 41 66 86 22 34 65 72 60 7 5 43 45 84 8 76 46 79 50 82 1 19 25 71 29 49 11 44 10 80 15 92 39 21 37 89 6 62 54 24 77 57 91 27 73 48 47 74 90 42 56 18 52 40 33 28 88 69 3 70 85 67 38 59 26 16 13 55 58 87 20 35 75 36 61 4 30 12 64 "
Y.47 = "20 88 13 34 75 76 35 19 39 52 65 37 5 55 70 78 51 11 33 64 25 27 41 15 79 28 16 36 21 69 87 61 43 85 90 1 23 57 73 40 45 63 59 72 10 8 92 29 80 24 48 6 46 77 3 49 18 86 4 53 26 82 58 83 74 30 56 42 17 12 66 81 60 68 67 47 22 14 91 62 50 44 7 84 9 2 71 38 54 32 89 31 "
Y.48 = "30 86 92 54 69 56 46 51 24 71 48 25 41 8 50 84 6 14 7 10 45 16 73 44 35 65 68 23 53 83 60 22 38 3 4 39 81 31 2 58 42 89 37 59 90 62 91 40 87 33 70 52 79 85 5 66 61 75 74 19 72 76 36 57 55 80 1 49 28 43 47 11 15 13 21 32 34 82 88 20 9 29 77 17 27 63 12 78 18 64 67 26 "
Y.49 = "79 70 3 61 9 8 58 91 63 36 82 17 53 28 55 27 59 26 90 86 71 25 7 89 45 24 73 40 1 60 51 57 4 44 52 34 75 62 56 84 87 72 76 35 85 14 18 38 65 29 31 69 80 83 32 48 50 2 43 10 13 23 19 11 54 67 77 22 21 6 81 37 42 49 30 41 66 88 15 92 39 16 68 20 46 47 12 64 74 33 78 5 "
Y.50 = "64 69 3 50 47 32 65 73 85 8 42 13 91 24 63 78 33 25 87 86 84 74 9 4 81 17 14 67 54 58 51 21 40 46 26 2 36 11 16 23 70 22 66 7 79 5 10 80 89 48 76 72 29 59 37 92 83 30 39 55 88 68 77 41 12 31 44 28 43 62 61 38 56 45 71 75 57 90 35 82 34 52 6 49 53 15 27 18 19 20 1 60 "
Y.51 = "33 59 12 88 55 26 29 53 43 23 39 34 16 87 83 7 86 4 56 72 81 32 92 40 17 35 69 82 57 80 27 77 2 78 31 75 84 8 3 13 48 42 46 70 49 9 54 73 79 51 91 37 62 64 1 22 71 50 25 67 38 11 66 20 63 45 47 28 14 5 10 65 41 74 52 44 19 90 60 89 76 61 58 68 18 15 85 36 21 24 6 30 "
Y.52 = "42 43 67 64 35 22 30 82 7 9 24 4 61 10 91 25 6 55 77 45 15 85 2 19 34 51 63 81 27 80 33 70 39 20 32 14 75 31 68 44 56 60 16 57 84 46 36 23 13 1 72 62 65 87 90 76 17 11 83 12 74 79 50 3 41 88 29 92 49 48 5 53 89 28 86 71 78 58 54 26 21 73 18 59 52 47 69 8 66 40 38 37 "
Y.53 = "33 58 75 39 3 19 41 67 23 17 31 66 47 28 74 13 70 9 80 91 68 15 56 52 14 18 27 4 43 5 20 88 36 30 54 16 49 45 82 37 6 55 84 50 32 2 11 26 65 46 22 25 7 51 34 63 38 92 29 87 42 86 78 1 21 53 35 44 77 79 81 73 8 72 61 89 48 85 10 76 90 40 71 60 24 69 83 57 12 64 59 62 "
Y.54 = "10 14 37 4 15 25 17 89 26 5 83 28 45 53 3 7 55 43 12 76 88 23 70 77 54 42 50 67 8 35 60 80 6 79 92 90 82 87 81 75 27 36 73 85 91 22 39 44 71 41 84 52 2 58 65 66 38 48 34 62 78 20 63 33 21 68 56 32 57 69 18 16 13 61 46 59 9 1 11 30 64 74 51 40 19 49 86 29 72 24 31 47 "
Y.55 = "72 82 67 23 69 38 78 35 90 11 51 62 54 5 21 75 37 48 6 57 87 76 86 63 55 31 34 8 47 25 7 49 91 14 41 46 71 40 32 24 29 4 92 27 26 56 73 15 61 53 77 1 22 70 12 66 83 42 2 60 80 74 18 28 45 13 36 10 85 50 44 9 39 52 89 20 84 30 79 81 3 33 68 88 64 43 16 17 59 19 65 58 "
Y.56 = "37 59 26 56 29 60 74 36 15 8 88 2 83 87 24 50 65 84 92 75 21 17 7 64 57 48 11 5 31 46 54 43 18 85 52 72 63 4 73 1 78 10 76 79 58 81 42 69 82 20 86 27 55 51 6 28 32 70 61 90 13 62 71 77 45 44 41 16 9 38 47 14 30 80 67 49 12 89 34 66 23 68 35 91 33 39 25 22 40 19 53 3 "
Y.57 = "61 78 44 51 12 83 80 86 46 7 34 66 64 70 59 37 27 47 92 23 84 90 45 17 49 55 36 89 31 58 85 5 14 20 25 32 29 26 54 50 87 38 18 68 82 13 8 91 48 19 76 72 10 65 57 41 60 71 52 69 67 1 28 35 53 88 43 22 30 75 4 56 62 11 77 73 24 63 9 81 16 3 21 39 40 42 74 2 33 79 6 15 "
Y.58 = "89 69 61 82 30 27 55 7 86 15 25 1 9 26 6 54 68 66 28 23 67 13 79 73 31 19 39 36 49 60 50 2 21 59 51 88 91 80 75 22 83 32 29 64 10 42 45 48 20 8 5 11 76 87 43 46 3 33 14 77 71 53 74 44 34 47 57 81 41 92 85 62 84 58 4 16 38 63 72 17 70 12 90 40 78 18 52 37 56 35 65 24 "
Y.59 = " 6 50 5 23 42 56 88 66 18 10 35 39 57 19 8 80 74 90 54 79 11 21 53 73 26 41 2 55 3 30 43 15 40 62 81 27 7 12 65 9 61 1 45 70 31 14 44 16 91 77 37 76 20 63 52 64 25 4 59 38 46 92 17 82 89 60 69 85 68 87 72 36 24 32 84 28 48 78 83 13 47 33 49 67 86 75 51 71 29 58 34 22 "
XRET = Y.N
RETURN (XRET)
ACLS: PROCEDURE; T = CHAROUT('','1b'x||'[2J');RETURN ;
APOS: PROCEDURE; ARG ROW,COL; T = CHAROUT('','1b'x||"["||ROW||";"||COL||"H");RETURN ;
ASAY: PROCEDURE; PARSE ARG ROW,COL,ATTR,TSTR ;
AF = "30 34 32 36 31 35 33 37 1;30 1;34 1;32 1;36 1;31 1;35 1;33 1;37" ;
AB = "40m 44m 42m 46m 41m 45m 43m 47m 5;40m 5;44m 5;42m 5;46m 5;41m 5;45m 5;43m 5;47m" ;
ESC = "1b"x||"["; CF = (ATTR // 16); CB = (((ATTR - CF) / 16) // 128) ;
FC = WORD(AF,(CF+1)); BC = WORD(AB,(CB+1)) ;
IF ROW = 0 THEN TSTR = ESC||"2J" ;
IF ROW <> 0 THEN TSTR = TSTR||ESC||"0m" ;
TC = ESC||FC||";"||BC; SP = ESC||ROW||";"||COL||"H"; T = CHAROUT('',SP||TC||TSTR) ;
RETURN
CRC32: PROCEDURE; PARSE ARG E,S ;
NUMERIC DIGITS 20
C= 'edb88320'x ;
F= 'ffFFffFF'x ;
DO I = 0 FOR 256
Z= D2C(I) ;
R= RIGHT(Z,4,'0'x) ;
DO J=0 FOR 8; ;
RB = X2B(C2X(R)) ;
R = X2C(B2X(0 || LEFT(RB,31))) ;
IF RIGHT(RB,1) THEN R = BITXOR(R,C) ;
END
E.Z = R ;
END
S=BITXOR(WORD(S '0000000'x, 1), F) ;
DO K=1 FOR LENGTH(E) ;
Q= BITXOR(RIGHT(S,1),SUBSTR(E,K,1))
S= BITXOR('0'x || LEFT(S,3),E.Q)
END
T = BITXOR(S,F)
RETURN C2X(T) ;
DTEST: DCF = 1; HF = 1
FL = "ZZ1.TXT ZZD.TXT ZZ2.TXT ZZZ.TXT"; ;
IF SL = "\" THEN 'DEL 'PTH'Z*.TXT';IF SL = "/" THEN 'rm 'PTH'Z*.TXT' ;
CALL ASAY 0,0,0,"";CALL ASAY 1,1,15,CENTER("Mark's Kryptos REXX",80) ;
CALL ASAY 2,1,31,"Enter Passphrase > "; PARSE PULL PW
IF PW == "" | WORDS(PW) == 0 THEN PW = "NSA Wyoming Rocks!" ;
PSBR = 0; CALL PPASS
CALL ASAY 3,1,12,"Passphrase = "PW
CALL ASAY 5,1,31,"String Encode/Decode Test";CALL TEST1 ;
CALL ASAY 6,1,12,PTO;CALL ASAY 7,1,15,ET;CALL ASAY 8,1,9,OP
CALL ASAY 10,1,31,"Encoding sequential file KT";CALL TEST2 ;
CALL ASAY 17,1,15,"Files ZZ1.TXT (Encode Text) and ZZD.TXT (Decoded text) created"
CALL ASAY 19,1,31,"Encoding sequential file KT to Binary";CALL TEST3 ;
CALL ASAY 21,1,7,"Files ZZ2.TXT (Binary Encode) and ZZZ.TXT (Binary Decode) created";
IF SL = "\" THEN DO CNT = 1 TO 4;'START NOTEPAD 'PTH||WORD(FL,CNT);END ;
IF SL = "/" THEN DO CNT = 1 TO 4;'geany 'PTH||WORD(FL,CNT)' </dev/null &>/dev/null &';END ;
RETURN
TEST1: ;
PTO = ""; PTO = "the quick brown fox jumps over the lazy dog." ;
PPP = 0;SB = 0;ET = "";ET = ENCODE(TRANS(PTO)); IF DCF = 0 THEN SAY ET ;
PPP = 0;SB = 0;OP = "";OP = UTRAN(DECODE(ET)); IF DCF = 0 THEN SAY OP ;
RETURN
TEST2: ;
SB = 3;PPP = 0;T = FSENCODE(PTH||"KT.REX",PTH||"ZZ1.TXT") ;
SB = 3;PPP = 0;T = FSDECODE(PTH||"ZZ1.TXT",PTH||"ZZD.TXT") ;
RETURN
TEST3: ;
PPP = 0; SB = 1; FIN = PTH||"KT.REX"; FOUT = PTH||"ZZ2.TXT"; TR = FBENCODE(FIN,FOUT) ;
PPP = 0; SB = 1; FIN = PTH||"ZZ2.TXT"; FOUT = PTH||"ZZZ.TXT"; TR = FBDECODE(FIN,FOUT) ;
RETURN