home *** CD-ROM | disk | FTP | other *** search
- PROC macro:
- global e$(1),f$(30),k$(100,30),l$(100,30),m$(1),p$(8),p1$(8),pp$(8),s$(30),t$(35),v$(30),q(8),n,m,o,p%,r%,f%
-
- rem ╔═══════════════════════════════════════╗
- rem ║ CodeSafe - ╕Huub Linthorst, 1997 ║
- rem ║ MacSys macro to store encrypted codes ║
- rem ║ E-mail: linthors@chem.leidenuniv.nl ║
- rem ╚═══════════════════════════════════════╝
-
- m$="w" rem Show mode [b(link) or w(indow)]
- e$="a" rem drive containing JBMACFIX.OPO (if present)
- f$="loc::m:\wrd\codesafe.wrd" rem File for data export
-
- v$="(1.5a) ─ ╕Huub Linthorst, 1997"
- useapp:("active")
- p%=actpid%:
- if info:(4)=0
- useapp:("system")
- tofront:
- endif
- t$="Master password"
- p4:
- endp
-
- proc p:
- busy ""
- tomacro:
- dinit "Password input"
- dxinput p1$,t$
- if dialog
- if len(p1$)>0
- p$=mid$(p1$+p1$+p1$+p1$+p1$+p1$+p1$+p1$,1,8)
- n=1
- while n<9
- q(n)=asc(mid$(p$,n,1))
- n=n+1
- endwh
- return
- endif
- endif
- endp
-
- proc p2:
- p2::
- p9:
- giprint:("CodeSafe is loading definitions...")
- busy "Writing file..."
- position 1
- while not eof
- k$(pos)=D.k$
- l$(pos)=D.l$
- next
- endwh
- if f%=1
- r%=1
- lopen f$
- lprint "FOR SAFETY, REMOVE THIS FILE ASAP!"
- lprint ""
- lprint ""
- while r%<pos
- lprint num$(r%,3)
- lprint k$(r%)
- p0:
- lprint s$
- lprint "───"
- r%=r%+1
- endwh
- close
- lclose
- busy "Enter to continue..."
- dinit
- dtext "","CodeSafe wrote data to file",2
- dtext "",f$,$202
- dtext ""," ",0
- dtext "","FOR SAFETY, REMOVE THIS FILE ASAP!",$102
- dtext ""," ",0
- dialog
- goto x::
- endif
- dinit:("View code ("+num$(pos-1,3)+" entries)")
- dchoicea:(1,"",addr(k$()),pos-1)
- r%=dialog:
- close
- if r%<>0
- p0:
- endif
- dinit:("")
- if m$="w"
- dtext:("Description:",k$(r%),0)
- dtext:("Secret code:",s$,$200)
- dtext:("","",0)
- else
- giprint:("Code: "+s$)
- endif
- dtext:("","View another code?",2)
- dbuttons:("Yes,%y,No,%n")
- r%=dialog:
- if r%=1
- goto p2::
- endif
- x::
- endp
-
- proc p4:
- if exist (f$)
- beep:(6,800)
- dinit:("CodeSafe Security")
- dtext:("","Found file",2)
- dtext:("",f$,2)
- dtext:("","",0)
- dtext:("","Remove now?",2)
- dbuttons:("Yes,%y,No,%n")
- r%=dialog:
- if r%=1
- delete f$
- endif
- endif
- dinit:("CodeSafe "+v$)
- dbuttons:("View,%v,Add,%a,Utilities,%u")
- r%=dialog:
- if r%<>0
- p:
- if len(p$)>0
- else
- goto x::
- endif
- endif
- if r%=1
- tofront:
- p2:
- elseif r%=2
- pp$=p$
- p$=" "
- t$="Confirm password"
- while p$<>pp$ and len(p$)>0
- p$=""
- p:
- t$="Wrong password, try again"
- endwh
- if len(p$)>0
- else
- goto x::
- endif
- p3:
- elseif r%=3
- tofront:
- dinit:("CodeSafe utilities")
- dbuttons:("Open database,%o,Print to file,%p,Change password,%c")
- r%=dialog:
- if r%=1
- if exist ("loc::"+e$+":\app\jbmacfix.opo")
- runjb:("data","m:\dat\codesafe.dat",actpid%:)
- else
- runappc:("data","m:\dat\codesafe.dat")
- return
- endif
- elseif r%=2
- tomacro:
- f%=1
- p2:
- elseif r%=3
- p5:
- endif
- endif
- x::
- usepid:(p%)
- tofront:
- endp
-
- proc p3:
- p3::
- k$(1)=""
- l$(1)=""
- dinit "Data entry"
- dedit k$(1),"Description"
- dedit l$(1),"Secret code"
- dialog
- if l$(1)=p1$
- beep 10,500
- t$="Master password may not be stored"
- goto p3a::
- elseif len(k$(1))>0
- r%=1
- o=1
- p0:
- p9:
- if count=100
- tofront:
- beep:(6,1000)
- giprint:("Max. number of records reached...")
- close
- return
- endif
- if len(l$(1))>0
- D.k$=k$(1)
- D.l$=s$
- append
- t$="Code stored"
- else
- beep 10,500
- t$="No entry"
- endif
- close
- p3a::
- dinit t$
- dtext "","Store another code?",2
- dbuttons "Yes",%y,"No",%n
- r%=dialog
- if r%=%y
- goto p3::
- endif
- endif
- tofront:
- x::
- endp
-
- proc p9:
- if exist ("loc::m:\dat\CodeSafe.dat")
- open "loc::m:\dat\CodeSafe.dat",D,k$,l$
- else
- create "loc::m:\dat\CodeSafe.dat",D,k$,l$
- endif
- return
- endp
-
- proc p0:
- s$=""
- n=8
- m=1
- while m<=len(l$(r%))
- if o=1
- s$=s$+chr$((asc(mid$(l$(r%),m,1)))+q(n))
- else
- s$=s$+chr$((asc(mid$(l$(r%),m,1)))-q(n))
- endif
- m=m+1
- n=n-1
- if n=0
- n=8
- endif
- endwh
- return
- endp
-
- proc p5:
- local qo(8),qn(8)
- t$="Confirm old master password"
- pp$=p$
- p$=" "
- while p$<>pp$ and len(p$)>0
- p$=""
- p:
- t$="Wrong password, try again"
- endwh
-
- if len(p$)>0
- else
- goto x::
- endif
-
- qo(1)=q(1)
- qo(2)=q(2)
- qo(3)=q(3)
- qo(4)=q(4)
- qo(5)=q(5)
- qo(6)=q(6)
- qo(7)=q(7)
- qo(8)=q(8)
- t$="New master password"
- p:
- pp$=p$
- p$=" "
- t$="Confirm new master password"
- while p$<>pp$ and len(p$)>0
- p$=""
- p:
- t$="Wrong password, try again"
- endwh
- if len(p$)>0
- else
- goto x::
- endif
- qn(1)=q(1)
- qn(2)=q(2)
- qn(3)=q(3)
- qn(4)=q(4)
- qn(5)=q(5)
- qn(6)=q(6)
- qn(7)=q(7)
- qn(8)=q(8)
- trap delete "m:\dat\codesafe.new"
- create "loc::m:\dat\codesafe.new",C,k$,l$
- p9:
- r%=1
- position 1
- while not eof
- q(1)=qo(1)
- q(2)=qo(2)
- q(3)=qo(3)
- q(4)=qo(4)
- q(5)=qo(5)
- q(6)=qo(6)
- q(7)=qo(7)
- q(8)=qo(8)
- o=0
- l$(1)=D.l$
- p0:
- if pos=1
- dinit "Check (first record only)"
- dtext "Description:",D.k$,0
- dtext "Secret code:",s$,$200
- dtext "","Is this correct?",2
- dbuttons "Yes",%y,"No",%n
- r%=dialog
- busy "Transferring data.."
- if r%=%y
- r%=1
- else
- close
- use C
- close
- tofront:
- giprint:("No new master password installed...")
- goto x::
- endif
- endif
- q(1)=qn(1)
- q(2)=qn(2)
- q(3)=qn(3)
- q(4)=qn(4)
- q(5)=qn(5)
- q(6)=qn(6)
- q(7)=qn(7)
- q(8)=qn(8)
- o=1
- l$(1)=s$
- p0:
- use C
- C.k$=D.k$
- C.l$=s$
- append
- use D
- next
- endwh
- close
- trap delete "m:\dat\codesafe.bak"
- rename "m:\dat\codesafe.dat","m:\dat\codesafe.bak"
- use C
- close
- beep:(5,700)
- rename "m:\dat\codesafe.new","m:\dat\codesafe.dat"
- tofront:
- dinit:("New master password installed")
- dtext:("","The old datafile has been saved as m:\dat\codesafe.bak.",2)
- dtext:("","You may want to remove this file for security.",$202)
- dtext:("","",0)
- dtext:("","Remove now?",2)
- dbuttons:("Yes,%y,No,%n")
- r%=dialog:
- if r%=1
- delete "m:\dat\codesafe.bak"
- endif
- x::
- endp
-
- proc runjb:(a$,f$,act%)
- rem ╕JBSoft 1996
- local buf%(128),name$(128),p%(6)
- name$="JBMSRS"
- pokew addr(buf%()),act%
- poke$ uadd(addr(buf%()),2),a$
- poke$ uadd(addr(buf%()),3+len(a$)),f$
- call($228b,0,255,6,addr(buf%()),addr(name$)+1)
- name$=parse$("jbmacfix.opo",cmd$(1),p%())
- runapp:(name$,"")
- endp
-
-