Advertisement
tyler569

Encrypt and Decrypt

Jul 8th, 2012
2,822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [topp]
  2. nomainwin
  3. UpperLeftX = 200
  4. UpperLeftY = 200
  5. WindowWidth = 375
  6. WindowHeight = 238
  7.  
  8.  
  9. BUTTON #win.go, "GO!", [start], UL, 215, 105, 49, 25
  10. BUTTON #win.end, "Close", [finished], UL, 255, 170, 50, 25
  11. RADIOBUTTON #win.eorde, "Encrypt", [encryptsub], wait, 30, 10, 75, 25
  12. RADIOBUTTON #win.eordd, "Decrypt", [decryptsub], wait, 110, 10, 75, 25
  13. STATICTEXT #win.words, "Word:", 46, 64, 30, 25
  14. TEXTBOX #win.word, 80, 59, 100, 25
  15. STATICTEXT #win.keys, "Key:", 196, 64, 25, 25
  16. TEXTBOX #win.key, 221, 59, 100, 25
  17. GROUPBOX #win.gi, "Input", 38, 41, 300, 55
  18. STATICTEXT #win.words, "Result:", 30, 142, 50, 25
  19. TEXTBOX #win.result, 80, 137, 245, 25
  20. open "Encrypt and Deccrypt" for window as #win
  21. wait
  22.  
  23.  
  24.  
  25. [start]
  26.  
  27. print #win.word, "!contents? word$"
  28. print #win.key, "!contents? key$"
  29.  
  30. [lword]
  31. dim letter$(len(word$))
  32. for loop1 = 1 to len(word$)
  33.     let letter$(loop1)=mid$(word$,loop1,1)
  34. next loop1
  35.  
  36. [lkey]
  37. dim key$(len(key$))
  38. for loop1 = 1 to len(key$)
  39.     let key$(loop1)=mid$(key$,loop1,1)
  40. next loop1
  41.  
  42. [convertword]
  43. dim wnumber(len(word$))
  44. for loop1 = 1 to len(word$)
  45.     let wnumber(loop1)=asc(letter$(loop1))
  46. next loop1
  47.  
  48. [convertkey]
  49. dim knumber(len(key$))
  50. for loop1 = 1 to len(key$)
  51.     let knumber(loop1)=asc(key$(loop1))
  52. next loop1
  53.  
  54. [encryptdecrypt]
  55. if eord$="e" then goto [encrypt]
  56. if eord$="d" then goto [decrypt]
  57.  
  58. [encrypt]
  59. dim encrypt(len(word$))
  60. let keyloop = 1
  61. for loop1 = 1 to len(word$)    'current error, add ascii, final far too high.  need new system / back to old
  62.     let encrypt(loop1)=wnumber(loop1)+knumber(keyloop)
  63.     if encrypt(loop1)>122 and wnumber(loop1)<=122 and wnumber(loop1)>=97 then let encrypt(loop1) = encrypt(loop1) - 26
  64.     if encrypt(loop1)>90 and wnumber(loop1)<=90 and wnumber(loop1)>=65 then let encrypt(loop1) = encrypt(loop1) - 26
  65.     if keyloop = len(key$) then keyloop = 1 else keyloop = keyloop + 1
  66. next loop1
  67. goto [encryptenter]
  68.  
  69. [decrypt]
  70. dim encrypt(len(word$))
  71. let keyloop = 1
  72. for loop1 = 1 to len(word$)
  73.     let encrypt(loop1)=wnumber(loop1)-knumber(keyloop)
  74.     if encrypt(loop1)<122 and wnumber(loop1)<=122 and wnumber(loop1)>=97 then let encrypt(loop1) = encrypt(loop1) + 26
  75.     if encrypt(loop1)>90 and wnumber(loop1)<=90 and wnumber(loop1)>=65 then let encrypt(loop1) = encrypt(loop1) + 26
  76.     if keyloop = len(key$) then keyloop = 1 else keyloop = keyloop + 1
  77. next loop1
  78.  
  79. [encryptenter]
  80. if eord$="e" or eord$="d" then goto [skip]
  81. notice "ERROR; Select 'Encrypt' or 'Decrypt'"
  82. close #win
  83. goto [topp]
  84. [skip]
  85.  
  86. [output]
  87. dim final$(len(word$))
  88. for loop1 = 1 to len(word$)
  89.     let final$(loop1)=chr$(encrypt(loop1)+96)
  90. next loop1
  91.  
  92. for loop1 = 1 to len(word$)
  93.    let finalw$=finalw$;final$(loop1)
  94. next loop1
  95. print #win.result, finalw$
  96. let finalw$ = ""
  97. wait
  98.  
  99. [end]
  100. close #win
  101. let finalw$ = ""
  102. goto [topp]
  103.  
  104. [finished]
  105. close #win
  106. end
  107.  
  108. [encryptsub]
  109. let eord$ = "e"
  110. wait
  111.  
  112. [decryptsub]
  113. let eord$ = "d"
  114. wait
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement