home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 85 / 085.d81 / filecrypt.s < prev    next >
Text File  |  2022-08-26  |  2KB  |  130 lines

  1. ;**encrypt/decrypt file
  2. ;by Jeff Jones
  3. ;open files in BASIC then 
  4. ;logical file 2 is source
  5. ;logical file 3 is output
  6. ;sys addr,"password" to encrypt
  7. ;sys addr+3,"password# to decrypt
  8. ;the longer the password, the better
  9.  
  10. open =$ffc0
  11. readst =$ffb7
  12. setlfs =$ffba
  13. setnam =$ffbd
  14. load =$ffd5
  15. getin =$ffe4
  16. clrchn =$ffcc
  17. close =$ffc3   ;a
  18. chrin =$ffcf
  19. chkout =$ffc9  ;x
  20. chkin =$ffc6   ;x
  21. plot =$fff0
  22. chrout =$ffd2
  23. color'pointer =243
  24. screen'line'pointer =209
  25. print'number =$bdcd ;x,a
  26. clear'line =59903
  27. password'index =251
  28. string'length =252
  29. temp =250
  30. flag =249
  31.  
  32. .org $033c
  33. ;mem
  34. .obj "@0:filecrypt.o"
  35.  
  36. jmp start
  37. jmp decrypt
  38.  
  39. start jsr get'password
  40.  
  41. jsr clrchn
  42. ldx #2
  43. jsr chkout
  44.  
  45. ldy #0
  46. sty password'index
  47. - lda $bdcd,y
  48. sty temp
  49. jsr scramble'unscramble
  50. jsr chrout
  51. ldy temp
  52. iny
  53. cpy #10
  54. bne -
  55.  
  56. lda #0
  57. sta password'index
  58.  
  59. encrypt'the'file jsr clrchn
  60. ldx #1
  61. jsr chkin
  62. jsr getin
  63. jsr scramble'unscramble
  64. sta temp
  65. jsr readst
  66. and #64
  67. bne close'files
  68. jsr clrchn
  69. ldx #2
  70. jsr chkout
  71. lda temp
  72. jsr chrout
  73. jmp encrypt'the'file
  74.  
  75. close'files lda #49
  76. sta 631
  77. inc 198
  78. jsr clrchn
  79. ldx #2
  80. jsr chkout
  81. lda temp
  82. jsr chrout
  83. jsr clrchn
  84. lda #1
  85. jsr close
  86. lda #2
  87. jmp close
  88.  
  89. decrypt jsr get'password
  90.  
  91. jsr clrchn
  92. ldx #1
  93. jsr chkin
  94.  
  95. ldy #0
  96. sty 198
  97. sty password'index
  98. - jsr getin
  99. sty temp
  100. jsr scramble'unscramble
  101. ldy temp
  102. cmp $bdcd,y
  103. bne close'files
  104. iny
  105. cpy #10
  106. bne -
  107.  
  108. lda #0
  109. sta password'index
  110. jmp encrypt'the'file
  111.  
  112.  
  113. get'password jsr $aefd
  114. jsr $ad9e
  115. jsr $b6a3
  116. sta string'length
  117. stx 253
  118. sty 254
  119. rts
  120.  
  121. scramble'unscramble ldy password'index
  122. inc password'index
  123. cpy string'length
  124. bcc +
  125. ldy #0
  126. sty password'index
  127. + eor (253),y
  128. rts
  129.  
  130.