home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PSION / 1997 / 996.ZIP / CODESAFE.MCR next >
Encoding:
Text File  |  1997-04-21  |  6.0 KB  |  378 lines

  1. PROC macro:
  2. 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%
  3.  
  4. rem ╔═══════════════════════════════════════╗
  5. rem ║ CodeSafe - ╕Huub Linthorst, 1997      ║
  6. rem ║ MacSys macro to store encrypted codes ║
  7. rem ║ E-mail: linthors@chem.leidenuniv.nl   ║
  8. rem ╚═══════════════════════════════════════╝
  9.  
  10. m$="w"   rem Show mode [b(link) or w(indow)]
  11. e$="a"   rem drive containing JBMACFIX.OPO (if present)
  12. f$="loc::m:\wrd\codesafe.wrd"   rem File for data export
  13.  
  14. v$="(1.5a) ─ ╕Huub Linthorst, 1997"
  15. useapp:("active")
  16. p%=actpid%:
  17. if info:(4)=0
  18.     useapp:("system")
  19.     tofront:
  20. endif
  21. t$="Master password"
  22. p4:
  23. endp
  24.  
  25. proc p:
  26. busy ""
  27. tomacro:
  28. dinit "Password input"
  29. dxinput p1$,t$
  30. if dialog
  31.     if len(p1$)>0
  32.         p$=mid$(p1$+p1$+p1$+p1$+p1$+p1$+p1$+p1$,1,8)
  33.         n=1
  34.         while n<9
  35.             q(n)=asc(mid$(p$,n,1))
  36.             n=n+1
  37.         endwh
  38.         return
  39.     endif
  40. endif
  41. endp
  42.  
  43. proc p2:
  44. p2::
  45. p9:
  46. giprint:("CodeSafe is loading definitions...")
  47. busy "Writing file..."
  48. position 1
  49. while not eof
  50.     k$(pos)=D.k$
  51.     l$(pos)=D.l$
  52.     next
  53. endwh
  54. if f%=1
  55.     r%=1
  56.     lopen f$
  57.     lprint "FOR SAFETY, REMOVE THIS FILE ASAP!"
  58.     lprint ""
  59.     lprint ""
  60.     while r%<pos
  61.         lprint num$(r%,3)
  62.         lprint k$(r%)
  63.         p0:
  64.         lprint s$
  65.         lprint "───"
  66.         r%=r%+1
  67.     endwh
  68.     close
  69.     lclose
  70.     busy "Enter to continue..."
  71.     dinit
  72.     dtext "","CodeSafe wrote data to file",2
  73.     dtext "",f$,$202
  74.     dtext ""," ",0
  75.     dtext "","FOR SAFETY, REMOVE THIS FILE ASAP!",$102
  76.     dtext ""," ",0
  77.     dialog
  78.     goto x::
  79. endif
  80. dinit:("View code   ("+num$(pos-1,3)+" entries)")
  81. dchoicea:(1,"",addr(k$()),pos-1)
  82. r%=dialog:
  83. close
  84. if r%<>0
  85.     p0:
  86. endif
  87. dinit:("")
  88. if m$="w"
  89.     dtext:("Description:",k$(r%),0)
  90.     dtext:("Secret code:",s$,$200)
  91.     dtext:("","",0)
  92. else
  93.     giprint:("Code: "+s$)
  94. endif
  95.     dtext:("","View another code?",2)
  96.     dbuttons:("Yes,%y,No,%n")
  97.     r%=dialog:
  98.     if r%=1
  99.         goto p2::
  100.     endif
  101. x::
  102. endp
  103.  
  104. proc p4:
  105. if exist (f$)
  106.     beep:(6,800)
  107.     dinit:("CodeSafe Security")
  108.     dtext:("","Found file",2)
  109.     dtext:("",f$,2)
  110.     dtext:("","",0)
  111.     dtext:("","Remove now?",2)
  112.     dbuttons:("Yes,%y,No,%n")
  113.     r%=dialog:
  114.     if r%=1
  115.         delete f$
  116.     endif
  117. endif
  118. dinit:("CodeSafe "+v$)
  119. dbuttons:("View,%v,Add,%a,Utilities,%u")
  120. r%=dialog:
  121. if r%<>0
  122.     p:
  123.     if len(p$)>0
  124.     else
  125.         goto x::
  126.     endif
  127. endif
  128. if r%=1
  129.     tofront:
  130.     p2:
  131. elseif r%=2
  132.     pp$=p$
  133.     p$=" "
  134.     t$="Confirm password"
  135.     while p$<>pp$ and len(p$)>0
  136.         p$=""
  137.         p:
  138.         t$="Wrong password, try again"
  139.     endwh
  140.     if len(p$)>0
  141.     else
  142.         goto x::
  143.     endif
  144.     p3:
  145. elseif r%=3
  146.     tofront:
  147.     dinit:("CodeSafe utilities")
  148.     dbuttons:("Open database,%o,Print to file,%p,Change password,%c")
  149.     r%=dialog:
  150.     if r%=1
  151.         if exist ("loc::"+e$+":\app\jbmacfix.opo")
  152.             runjb:("data","m:\dat\codesafe.dat",actpid%:)
  153.         else 
  154.             runappc:("data","m:\dat\codesafe.dat")
  155.             return
  156.         endif
  157.     elseif r%=2
  158.         tomacro:
  159.         f%=1
  160.         p2:
  161.     elseif r%=3
  162.         p5:
  163.     endif
  164. endif
  165. x::
  166. usepid:(p%)
  167. tofront:
  168. endp
  169.  
  170. proc p3:
  171. p3::
  172. k$(1)=""
  173. l$(1)=""
  174. dinit "Data entry"
  175. dedit k$(1),"Description"
  176. dedit l$(1),"Secret code"
  177. dialog
  178. if l$(1)=p1$
  179.     beep 10,500
  180.     t$="Master password may not be stored"
  181.     goto p3a::
  182. elseif len(k$(1))>0
  183.     r%=1
  184.     o=1
  185.     p0:
  186.     p9:
  187.     if count=100
  188.         tofront:
  189.         beep:(6,1000)
  190.         giprint:("Max. number of records reached...")
  191.         close
  192.         return
  193.     endif
  194.     if len(l$(1))>0
  195.         D.k$=k$(1)
  196.         D.l$=s$
  197.         append
  198.         t$="Code stored"
  199.     else
  200.         beep 10,500
  201.         t$="No entry"
  202.     endif
  203.     close
  204.     p3a::
  205.     dinit t$
  206.     dtext "","Store another code?",2
  207.     dbuttons "Yes",%y,"No",%n
  208.     r%=dialog
  209.     if r%=%y
  210.         goto p3::
  211.     endif
  212. endif
  213. tofront:
  214. x::
  215. endp
  216.  
  217. proc p9:
  218. if exist ("loc::m:\dat\CodeSafe.dat")
  219.     open "loc::m:\dat\CodeSafe.dat",D,k$,l$
  220. else
  221.     create "loc::m:\dat\CodeSafe.dat",D,k$,l$
  222. endif
  223. return
  224. endp
  225.  
  226. proc p0:
  227. s$=""
  228. n=8
  229. m=1
  230. while m<=len(l$(r%))
  231.     if o=1
  232.         s$=s$+chr$((asc(mid$(l$(r%),m,1)))+q(n))
  233.     else
  234.         s$=s$+chr$((asc(mid$(l$(r%),m,1)))-q(n))
  235.     endif
  236.     m=m+1
  237.     n=n-1
  238.     if n=0
  239.         n=8
  240.     endif
  241. endwh
  242. return
  243. endp
  244.  
  245. proc p5:
  246. local qo(8),qn(8)
  247. t$="Confirm old master password"
  248. pp$=p$
  249. p$=" "
  250. while p$<>pp$ and len(p$)>0
  251.     p$=""
  252.     p:
  253.     t$="Wrong password, try again"
  254. endwh
  255.  
  256. if len(p$)>0
  257. else
  258.     goto x::
  259. endif
  260.  
  261. qo(1)=q(1)
  262. qo(2)=q(2)
  263. qo(3)=q(3)
  264. qo(4)=q(4)
  265. qo(5)=q(5)
  266. qo(6)=q(6)
  267. qo(7)=q(7)
  268. qo(8)=q(8)
  269. t$="New master password"
  270. p:
  271. pp$=p$
  272. p$=" "
  273. t$="Confirm new master password"
  274. while p$<>pp$ and len(p$)>0
  275.     p$=""
  276.     p:
  277.     t$="Wrong password, try again"
  278. endwh
  279. if len(p$)>0
  280. else
  281.     goto x::
  282. endif
  283. qn(1)=q(1)
  284. qn(2)=q(2)
  285. qn(3)=q(3)
  286. qn(4)=q(4)
  287. qn(5)=q(5)
  288. qn(6)=q(6)
  289. qn(7)=q(7)
  290. qn(8)=q(8)
  291. trap delete "m:\dat\codesafe.new"
  292. create "loc::m:\dat\codesafe.new",C,k$,l$
  293. p9:
  294. r%=1
  295. position 1
  296. while not eof
  297.     q(1)=qo(1)
  298.     q(2)=qo(2)
  299.     q(3)=qo(3)
  300.     q(4)=qo(4)
  301.     q(5)=qo(5)
  302.     q(6)=qo(6)
  303.     q(7)=qo(7)
  304.     q(8)=qo(8)
  305.     o=0
  306.     l$(1)=D.l$
  307.     p0:
  308.     if pos=1
  309.         dinit "Check (first record only)"
  310.         dtext "Description:",D.k$,0
  311.         dtext "Secret code:",s$,$200
  312.         dtext "","Is this correct?",2
  313.         dbuttons "Yes",%y,"No",%n
  314.         r%=dialog
  315.         busy "Transferring data.."
  316.         if r%=%y
  317.         r%=1
  318.         else
  319.             close
  320.             use C
  321.             close
  322.             tofront:
  323.             giprint:("No new master password installed...")
  324.             goto x::
  325.         endif
  326.     endif
  327.     q(1)=qn(1)
  328.     q(2)=qn(2)
  329.     q(3)=qn(3)
  330.     q(4)=qn(4)
  331.     q(5)=qn(5)
  332.     q(6)=qn(6)
  333.     q(7)=qn(7)
  334.     q(8)=qn(8)
  335.     o=1
  336.     l$(1)=s$
  337.     p0:
  338.     use C
  339.     C.k$=D.k$
  340.     C.l$=s$
  341.     append
  342.     use D
  343.     next
  344. endwh
  345. close
  346. trap delete "m:\dat\codesafe.bak"
  347. rename "m:\dat\codesafe.dat","m:\dat\codesafe.bak"
  348. use C
  349. close
  350. beep:(5,700)
  351. rename "m:\dat\codesafe.new","m:\dat\codesafe.dat"
  352. tofront:
  353. dinit:("New master password installed")
  354. dtext:("","The old datafile has been saved as m:\dat\codesafe.bak.",2)
  355. dtext:("","You may want to remove this file for security.",$202)
  356. dtext:("","",0)
  357. dtext:("","Remove now?",2)
  358. dbuttons:("Yes,%y,No,%n")
  359. r%=dialog:
  360. if r%=1
  361.     delete "m:\dat\codesafe.bak"
  362. endif
  363. x::
  364. endp
  365.  
  366. proc runjb:(a$,f$,act%)
  367. rem ╕JBSoft 1996
  368. local buf%(128),name$(128),p%(6)
  369. name$="JBMSRS"
  370. pokew addr(buf%()),act%
  371. poke$ uadd(addr(buf%()),2),a$
  372. poke$ uadd(addr(buf%()),3+len(a$)),f$
  373. call($228b,0,255,6,addr(buf%()),addr(name$)+1)
  374. name$=parse$("jbmacfix.opo",cmd$(1),p%())
  375. runapp:(name$,"")
  376. endp
  377.  
  378.