-
Notifications
You must be signed in to change notification settings - Fork 0
/
APRSPASS.BAS
35 lines (35 loc) · 1.3 KB
/
APRSPASS.BAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
100 REM GENERATE APRS-IS PASSCODE
110 REM WRITTEN FOR GW-BASIC
120 REM T. DE LELLIS / KN6EI / DL5MGZ
130 REM
140 REM DEFINE SET OF VALID APRS-IS LOGIN CHARACTERS
150 VALID$="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
160 REM CONVERT CHARACTER TO UPPERCASE
170 DEF FNU(X)=X-(32*ABS(((X>=97) AND (X<=122))))
180 REM CHECK IF VALID CALLSIGN CHARACTER
190 DEF FNV(X)=INSTR(VALID$,CHR$(X))
200 CLS
210 PRINT "Generate APRS-IS Passcode"
220 PRINT
230 INPUT "Enter APRS-IS server login (callsign): ",LOGIN$
240 REM CHECK FOR VALID LOGIN
250 IF LEN(LOGIN$)<1 OR LEN(LOGIN$)>9 THEN PRINT "Error: Login must be 1-9 characters long":GOTO 220
260 BADC=0
270 FOR J=1 TO LEN(LOGIN$)
280 C=ASC(MID$(LOGIN$,J,1))
290 IF FNV(FNU(C))=0 THEN BADC=1:PRINT "Error: Invalid character '";CHR$(C);"'"
300 NEXT J
310 IF BADC THEN PRINT "Login may only consist of the following characters:":PRINT VALID$:GOTO 220
320 REM REMOVE ANY POSSIBLE SSID FOR COMPUTATION
330 SSID=INSTR(LOGIN$,"-")
340 IF SSID>0 THEN LOGIN$=LEFT$(LOGIN$,SSID-1)
350 REM COMPUTE PASSCODE
360 HASH=&H73E2
370 FOR J=1 TO LEN(LOGIN$)
380 C=FNU(ASC(MID$(LOGIN$,J,1)))
390 REM ODD ITERATIONS MANIPULATE HASH HIGH-BYTE, EVEN ITERATIONS LOW-BYTE
400 IF J MOD 2 THEN HASH=HASH XOR (C*256) ELSE HASH=HASH XOR C
410 NEXT J
420 PRINT "Passcode =";HASH
430 END