S- - 4


pp% = INSTR(sp0% + 1, plainf$, ".")

IF pp% = 0 THEN

dcipherf$ = plainf$ + ".DES"

ELSE

dcipherf$ = LEFT$(plainf$, pp% - 1) + ".DES"

END IF

PRINT " : "; dcipherf$

INPUT " : ", cipherf$

IF cipherf$ = "" THEN cipherf$ = dcipherf$

OPEN cipherf$ FOR RANDOM AS 2

IF LOF(2) > 0 THEN

CLOSE #2

PRINT : PRINT " !"

SYSTEM

ELSE

CLOSE #2

OPEN cipherf$ FOR binary AS 2

END IF

PW$ = ""

LOCATE 9, 1

INPUT ; " : ", PW$

IF (LEN(PW$) < 8) THEN PW$ = PW$ + STRING$(8 - LEN(PW$), 0)

IF len(pw$) = 16 then

LOCATE 9, 8: PRINT " : "; STRING$(16, 15); STRING$(10, " ")

PW$ = ucase$(PW$)

xtob PW$, P2()

ELSE

LOCATE 9, 8: PRINT " : "; STRING$(8, 15); STRING$(10, " ")

PW$ = LEFT$(PW$, 8)

stob PW$, P2()

end IF

18.3

transpose P2(), KeyTr1(), 56

ciphertekst$ = ""

blocks& = lof1& \ 256

w = RND(-INT(TIMER))

anything$ = ""

FOR i% = 1 TO 12

anything$ = anything$ + CHR$(128 + INT(127 * RND(1)))

NEXT i%

header$ = "#" + LTRIM$(STR$(lof1&))

header$ = "DES" + LEFT$(anything$, 8 - LEN(header$)) + header$

header$ = header$ + RIGHT$(anything$, 12 - LEN(bplainf$)) +

"#" + bplainf$

cheader$=desalg$(left$(header$,8))+desalg$(MID$(header$,9,8))+desalg$(right$(header$,8))

put$ #2, cheader$

LOCATE 10, 8: PRINT ; ": 0 %";

inblock$=space$(256)

FOR n& = 1 TO blocks&

get$ #1,256,inblock$

outblock$=""

for b%=1 to 256 step 8

outblock$ = outblock$+desalg$(mid$(inblock$,b%,8))

next

Put$ #2, outblock$

LOCATE 10, 19: PRINT ; USING "###"; (n& / blocks&) * 100;

NEXT n&

rest1 = lof1& MOD 256

rest2 = lof1& MOD 8

rest = rest1-rest2

IF rest1 > 0 THEN