 Rem File: Passwrd5.bas - for Dndcnvt/Dndcnvt2/Dndutil/Makecnfg
 Rem $Include: 'dndbbs.inc'

SUB Passwrd1(Var)
 ON LOCAL ERROR GOTO ErrResume1
 DIM File.Byte AS STRING * 1
 Var = True
 CLOSE
 DND.Path$ = ENVIRON$("DNDBBS")
 IF DND.Path$ <> Nul THEN
    IF RIGHT$(DND.Path$, 1) <> "\" THEN
       DND.Path$ = DND.Path$ + "\"
    END IF
 END IF
 FileName$ = DND.Path$ + "DNDCNVT.EXE"
 OPEN FileName$ FOR BINARY AS #1
 File.Length! = LOF(1)
 GET #1, File.Length!, File.Byte
 Byte.Value = ASC(File.Byte)
 Password$ = Nul
 IF Byte.Value = 255 THEN
    FOR File.Position! = File.Length! - 20 TO File.Length! - 1
       GET #1, File.Position!, File.Byte
       Password$ = Password$ + File.Byte
    NEXT
    CALL Crypto(Password$)
    Password$ = RTRIM$(Password$)
    IF Password$ = Nul THEN
       EXIT SUB
    END IF
    COLOR 15, 0
    PRINT "Enter password: ";
    LOCATE , , 1
    Var1$ = Nul
    DO
       Input.Char$ = Nul
       WHILE Input.Char$ = Nul
          Input.Char$ = INKEY$
       WEND
       IF Input.Char$ = CHR$(13) THEN
          EXIT DO
       END IF
       Var1$ = Var1$ + Input.Char$
       Print "#";
    LOOP
    PRINT
    IF Password$ <> Var1$ THEN
       Var = False
    END IF
 END IF
ErrExit1:
 EXIT SUB
ErrResume1:
 RESUME ErrExit1
END SUB

SUB Passwrd2(Var)
 ON LOCAL ERROR GOTO ErrResume2
 DIM File.Byte AS STRING * 1
 Var = True
 CLOSE
 DND.Path$ = ENVIRON$("DNDBBS")
 IF DND.Path$ <> Nul THEN
    IF RIGHT$(DND.Path$, 1) <> "\" THEN
       DND.Path$ = DND.Path$ + "\"
    END IF
 END IF
 FileName$ = DND.Path$ + "DNDCNVT2.EXE"
 OPEN FileName$ FOR BINARY AS #1
 File.Length! = LOF(1)
 GET #1, File.Length!, File.Byte
 Byte.Value = ASC(File.Byte)
 Password$ = Nul
 IF Byte.Value = 255 THEN
    FOR File.Position! = File.Length! - 20 TO File.Length! - 1
       GET #1, File.Position!, File.Byte
       Password$ = Password$ + File.Byte
    NEXT
    CALL Crypto(Password$)
    Password$ = RTRIM$(Password$)
    IF Password$ = Nul THEN
       EXIT SUB
    END IF
    COLOR 15, 0
    PRINT "Enter password: ";
    LOCATE , , 1
    Var1$ = Nul
    DO
       Input.Char$ = Nul
       WHILE Input.Char$ = Nul
          Input.Char$ = INKEY$
       WEND
       IF Input.Char$ = CHR$(13) THEN
          EXIT DO
       END IF
       Var1$ = Var1$ + Input.Char$
       Print "#";
    LOOP
    PRINT
    IF Password$ <> Var1$ THEN
       Var = False
    END IF
 END IF
ErrExit2:
 EXIT SUB
ErrResume2:
 RESUME ErrExit2
END SUB

Sub Passwrd7(Var)
 On Local Error Goto Error.Trap7
 Dim File.Byte As String*1
 Var=True
 Close #TempFile1
 FileName=DND.Path+"MAKECNFG.EXE"
 Open FileName For Binary As #TempFile1
 File.Length!=Lof(TempFile1)
 Get #TempFile1,File.Length!,File.Byte
 Var1=Asc(File.Byte)
 Password$=Nul
 If Var1=255 Then
    For File.Position!=File.Length!-20 To File.Length!-1
       Get #TempFile1,File.Position!,File.Byte
       Password$=Password$+File.Byte
    Next
    For VarX=1 To Len(Password$)
       VarZ=Asc(Mid$(Password$,VarX,1)) Xor Len(Password$)
       Mid$(Password$,VarX,1)=Chr$(VarZ)
    Next
    Password$=Rtrim$(Password$)
    If Password$=Nul Then
       Exit Sub
    Endif
    Color 15, 0
    Print "Enter password: ";
    Locate ,,1
    TempA$=Nul
    Do
       Input.Char$=Nul
       While Input.Char$=Nul
          Input.Char$=Inkey$
       Wend
       If Input.Char$=Chr$(13) Then
          Exit Do
       Endif
       TempA$=TempA$+Input.Char$
       Print "#";
    Loop
    Print
    If TempA$<>Password$ Then
       Print "Illegal password!"
       Var=False
    Endif
 Endif
Error.Resume7:
 Exit Sub
Error.Trap7:
 Resume Error.Resume7
End Sub

Sub Passwrd8(Var)
 On Local Error Goto Error.Trap8
 Dim File.Byte As String*1
 Var=True
 Close #1
 FileName=DND.Path+"DNDUTIL.EXE"
 Open FileName For Binary As #1
 File.Length!=Lof(1)
 Get 1,File.Length!,File.Byte
 Byte.Value=Asc(File.Byte)
 Password$=Nul
 If Byte.Value=255 Then
    For File.Position!=File.Length!-20 To File.Length!-1
       Get 1,File.Position!,File.Byte
       Password$=Password$+File.Byte
    Next
    Call Crypto(Password$)
    Password$=Rtrim$(Password$)
    If Password$=Nul Then
       Exit Sub
    Endif
    Color 15,0
    Print "Enter password: ";
    Locate ,,1
    TempA$=Nul
    Do
       Input.Char$=Nul
       While Input.Char$=Nul
          Input.Char$=Inkey$
       Wend
       If Input.Char$=Chr$(13) Then
          Exit Do
       Endif
       TempA$=TempA$+Input.Char$
       Print "#";
    Loop
    Print
    If TempA$<>Password$ Then
       Color 14,0
       Print "Illegal password!"
       Var=False
    Endif
 Endif
Error.Resume8:
 Exit Sub
Error.Trap8:
 Resume Error.Resume8
End Sub
