Bestimmte Stelle in Textbox lesen

  • VB.NET

Es gibt 5 Antworten in diesem Thema. Der letzte Beitrag () ist von Manschula.

    Bestimmte Stelle in Textbox lesen

    Hallo Leute!
    Ich arbeite gerade an einem Text-Verschlüsselungs-Programm. Dazu möchte ich einen Verschlüsselungs-Algorhythmus erstellen, indem jemand den Text schreibt und darunter ein Passwort eingibt, nach dem der Text verschlüsselt wird. Dazu hatte ich die Idee, dass halt, wenn z.B.

    VB.NET-Quellcode

    1. If <<Code den ich brauch, also nach dem Muster Zeichen 1 = a>> then
    2. <<hier werden halt die Buchstaben aus dem Text verschlüsselt ausgegeben>>


    Also ist meine Frage, ob es überhaupt klug ist nach diesem Muster vorzugehen, und wenn ja, wie denn der mögliche code aussehen könnte, wobei die einzelnen zeichen des Passworts gelesen und demnach Verschlüsselt werden.

    Hier nochmal mein aktuelles Skript:
    Spoiler anzeigen

    VB.NET-Quellcode

    1. Public Class Form1
    2. Dim X As String = "", _
    3. V As String = ""
    4. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5. End Sub
    6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    7. Dim str As String, Newstr As String = Nothing
    8. str = TextBox1.Text
    9. For Each StrText As String In str
    10. Select Case True
    11. 'chars
    12. Case StrText = "a"
    13. StrText = "c"
    14. Case StrText = "b"
    15. StrText = "d"
    16. Case StrText = "c"
    17. StrText = "e"
    18. Case StrText = "d"
    19. StrText = "f"
    20. Case StrText = "e"
    21. StrText = "g"
    22. Case StrText = "f"
    23. StrText = "h"
    24. Case StrText = "g"
    25. StrText = "i"
    26. Case StrText = "h"
    27. StrText = "j"
    28. Case StrText = "i"
    29. StrText = "k"
    30. Case StrText = "j"
    31. StrText = "l"
    32. Case StrText = "k"
    33. StrText = "m"
    34. Case StrText = "l"
    35. StrText = "n"
    36. Case StrText = "m"
    37. StrText = "o"
    38. Case StrText = "n"
    39. StrText = "p"
    40. Case StrText = "o"
    41. StrText = "q"
    42. Case StrText = "p"
    43. StrText = "r"
    44. Case StrText = "q"
    45. StrText = "s"
    46. Case StrText = "r"
    47. StrText = "t"
    48. Case StrText = "s"
    49. StrText = "u"
    50. Case StrText = "t"
    51. StrText = "v"
    52. Case StrText = "u"
    53. StrText = "w"
    54. Case StrText = "v"
    55. StrText = "x"
    56. Case StrText = "w"
    57. StrText = "y"
    58. Case StrText = "x"
    59. StrText = "z"
    60. Case StrText = "y"
    61. StrText = "a"
    62. Case StrText = "z"
    63. StrText = "b"
    64. 'nums
    65. Case StrText = "1"
    66. StrText = "3"
    67. Case StrText = "2"
    68. StrText = "4"
    69. Case StrText = "3"
    70. StrText = "5"
    71. Case StrText = "4"
    72. StrText = "6"
    73. Case StrText = "5"
    74. StrText = "7"
    75. Case StrText = "6"
    76. StrText = "8"
    77. Case StrText = "7"
    78. StrText = "9"
    79. Case StrText = "8"
    80. StrText = "0"
    81. Case StrText = "9"
    82. StrText = "1"
    83. Case StrText = "0"
    84. StrText = "2"
    85. 'UPER CASE
    86. Case StrText = "A"
    87. StrText = "C"
    88. Case StrText = "B"
    89. StrText = "D"
    90. Case StrText = "C"
    91. StrText = "E"
    92. Case StrText = "D"
    93. StrText = "F"
    94. Case StrText = "E"
    95. StrText = "G"
    96. Case StrText = "F"
    97. StrText = "H"
    98. Case StrText = "G"
    99. StrText = "I"
    100. Case StrText = "H"
    101. StrText = "J"
    102. Case StrText = "I"
    103. StrText = "K"
    104. Case StrText = "J"
    105. StrText = "L"
    106. Case StrText = "K"
    107. StrText = "M"
    108. Case StrText = "L"
    109. StrText = "N"
    110. Case StrText = "M"
    111. StrText = "O"
    112. Case StrText = "N"
    113. StrText = "P"
    114. Case StrText = "O"
    115. StrText = "Q"
    116. Case StrText = "P"
    117. StrText = "R"
    118. Case StrText = "Q"
    119. StrText = "S"
    120. Case StrText = "R"
    121. StrText = "T"
    122. Case StrText = "S"
    123. StrText = "U"
    124. Case StrText = "T"
    125. StrText = "V"
    126. Case StrText = "U"
    127. StrText = "W"
    128. Case StrText = "V"
    129. StrText = "X"
    130. Case StrText = "W"
    131. StrText = "Y"
    132. Case StrText = "X"
    133. StrText = "Z"
    134. Case StrText = "Y"
    135. StrText = "A"
    136. Case StrText = "Z"
    137. StrText = "B"
    138. 'Secial Char
    139. Case StrText = "½"
    140. StrText = "#"
    141. Case StrText = "!"
    142. StrText = "¤"
    143. Case StrText = "#"
    144. StrText = "%"
    145. Case StrText = "¤"
    146. StrText = "&"
    147. Case StrText = "%"
    148. StrText = "/"
    149. Case StrText = "&"
    150. StrText = "("
    151. Case StrText = "/"
    152. StrText = ")"
    153. Case StrText = "("
    154. StrText = "="
    155. Case StrText = ")"
    156. StrText = "?"
    157. Case StrText = "="
    158. StrText = "`"
    159. Case StrText = "?"
    160. StrText = "^"
    161. Case StrText = "`"
    162. StrText = "*"
    163. Case StrText = "^"
    164. StrText = ">"
    165. Case StrText = "*"
    166. StrText = ","
    167. Case StrText = ">"
    168. StrText = "."
    169. Case StrText = ","
    170. StrText = "-"
    171. Case StrText = "."
    172. StrText = "§"
    173. Case StrText = "-"
    174. StrText = "@"
    175. Case StrText = "§"
    176. StrText = "£"
    177. Case StrText = "@"
    178. StrText = "$"
    179. Case StrText = "£"
    180. StrText = "€"
    181. Case StrText = "$"
    182. StrText = "{"
    183. Case StrText = "€"
    184. StrText = "["
    185. Case StrText = "{"
    186. StrText = "]"
    187. Case StrText = "["
    188. StrText = "}"
    189. Case StrText = "]"
    190. StrText = "\"
    191. Case StrText = "}"
    192. StrText = "´"
    193. Case StrText = "\"
    194. StrText = "¨"
    195. Case StrText = "´"
    196. StrText = "'"
    197. Case StrText = "¨"
    198. StrText = "<"
    199. Case StrText = "~"
    200. StrText = ";"
    201. Case StrText = "<"
    202. StrText = ":"
    203. Case StrText = ";"
    204. StrText = "_"
    205. Case StrText = ":"
    206. StrText = "|"
    207. Case StrText = "_"
    208. StrText = "½"
    209. Case StrText = "|"
    210. StrText = "!"
    211. Case True
    212. For I = 0 To X.Length - 1
    213. StrText = StrText.Replace(V.ElementAt(I), _
    214. X.ElementAt(I))
    215. Next
    216. End Select
    217. Newstr &= StrText
    218. Next
    219. TextBox1.Text = Newstr
    220. End Sub
    221. Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
    222. End Sub
    223. End Class

    achja und button1 ist der butten, der wenn ich etwas in textbox1 eingegeben habe, den text verschlüsselt.


    Edit by Manschula: Überlanger Codeausschnitt in Expander gepackt

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Manschula“ ()