S- - 7


letbe bdes(), ades(), 64

FOR j% = 1 TO 32

ades(j%) = bdes(j% + 32)

NEXT j%

f i%, ades(), xdes()

FOR j% = 1 TO 32

ades(j% + 32) = (bdes(j%) + xdes(j%)) MOD 2

18.3

NEXT j%

NEXT i%

transpose ades(), swappy(), 64

transpose ades(), FinalTr(), 64

btos ades(), temp$

desalg$ = temp$

END FUNCTION

SUB f (i%, a() AS INTEGER, x() AS INTEGER)

h% = i%: letbe EF(), a(), 64

transpose EF(), etr(), 48

FOR j% = 1 TO rots(h%)

mrotate P2()

NEXT j%

letbe ikeyf(), P2(), 64: transpose ikeyf(), KeyTr2(), 48

FOR j% = 1 TO 48

yf(j%) = (EF(j%) + ikeyf(j%)) MOD 2

NEXT j%

FOR k% = 1 TO 8

k6% = 6 * k%: k4% = 4 * k%

r% = (32 * yf(k6% - 5)) + (16 * yf(k6%)) + (8 * yf(k6% - 4)) + (4 * yf(k6% - 3)) + (2 * yf(k6% - 2)) + yf(k6% - 1) + 1

x(k4% - 3) = (s(k%, r%) \ 8) MOD 2: x(k4% - 2) = (s(k%, r%) \ 4) MOD 2

x(k4% - 1) = (s(k%, r%) \ 2) MOD 2: x(k4%) = s(k%, r%) MOD 2

NEXT k%

transpose x(), ptr(), 32

END SUB

SUB init (x() AS INTEGER, n%)

FOR i% = 1 TO n%

READ x(i%)

NEXT i%

END SUB

SUB letbe (target() AS INTEGER, source() AS INTEGER, LAST%)

FOR i% = 1 TO LAST%

target(i%) = source(i%)

NEXT i%

END SUB

18.3

FUNCTION MYBIN$ (n%)

LOCAL ST$

p% = n%

ST$=""

FOR i% = 1 TO 8

IF (p% MOD 2) THEN

ST$ = "1" + ST$

ELSE

ST$ = "0" + ST$

END IF

p% = p% \ 2

NEXT i%

MYBIN$ = ST$

END FUNCTION

SUB mrotate (keyr() AS INTEGER)

letbe XR(), keyr(), 56

FOR i% = 1 TO 55

XR(i%) = XR(i% + 1)

NEXT i%

XR(28) = keyr(1): XR(56) = keyr(29)

letbe keyr(), XR(), 56

END SUB

SUB sboxinit (b() AS INTEGER)

RESTORE sboxesl

FOR i% = 1 TO 8

FOR j% = 1 TO 64

READ b(i%, j%)

NEXT j%

NEXT i%

END SUB

SUB stob (a$, mbits() AS INTEGER)

FOR i% = 1 TO 8

b$ = MYBIN$(ASC(MID$(a$, i%, 1)))

FOR j% = 1 TO 8

mbits(((i% - 1) * 8) + j%) = ASC(MID$(b$, j%, 1)) - 48