11-17-2022, 10:59 AM
(This post was last modified: 11-17-2022, 11:13 AM by AtomicSlaughter.)
Ok, here is a simple program to encode text with a shifting cypher.
Usage:-
crypt encode 1234 "your data"
crypt decode 1234 "encoded data"
Usage:-
crypt encode 1234 "your data"
crypt decode 1234 "encoded data"
Code: (Select All)
$CONSOLE:ONLY
CLS
DIM SHARED AS STRING phrase, message, code
REDIM SHARED AS INTEGER sCode(0)
phrase = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SplitCode
SELECT CASE LCASE$(COMMAND$(1))
CASE "encode"
en$ = EnCode
PRINT "EnCode<", en$
_CLIPBOARD$ = en$
PRINT
PRINT "encoded message has been copied to clipboard"
SYSTEM
CASE "decode"
de$ = DeCode
PRINT "DeCode>", de$
_CLIPBOARD$ = de$
SYSTEM
END SELECT
FUNCTION DeCode$
DIM AS STRING t, h, e
DIM AS INTEGER c
c = 1
h = UCASE$(COMMAND$(3))
FOR i = 1 TO LEN(h)
FOR x = 1 TO LEN(phrase)
IF MID$(h, i, 1) = MID$(phrase, x, 1) THEN
e = e + MID$(phrase, x - sCode(c), 1)
EXIT FOR
END IF
NEXT x
IF c = 4 THEN c = 1 ELSE c = c + 1
NEXT i
DeCode = dehex(e)
END FUNCTION
FUNCTION EnCode$
DIM AS STRING t, h, e
DIM AS INTEGER c
c = 1
h = toHex(COMMAND$(3))
FOR i = 1 TO LEN(h)
FOR x = 1 TO LEN(phrase)
IF MID$(h, i, 1) = MID$(phrase, x, 1) THEN
e = e + MID$(phrase, x + sCode(c), 1)
EXIT FOR
END IF
NEXT x
IF c = 4 THEN c = 1 ELSE c = c + 1
NEXT i
EnCode = e
END FUNCTION
SUB SplitCode
REDIM sCode(LEN(COMMAND$(2))) AS INTEGER
FOR i = i TO LEN(COMMAND$(2))
sCode(i) = VAL(MID$(COMMAND$(2), i, 1))
NEXT
END SUB
FUNCTION dehex$ (m AS STRING)
DIM s AS STRING
FOR i = 1 TO LEN(m) STEP 2
s = s + CHR$(VAL("&h" + MID$(m, i, 2)))
dehex = s
NEXT
END FUNCTION
FUNCTION toHex$ (m AS STRING)
DIM s AS STRING
FOR i = 1 TO LEN(m)
s = s + HEX$(ASC(MID$(m, i, 1)))
toHex = s
NEXT
END FUNCTION