Console Buchstabe durch Zahl ersetzen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von markus.obi.

    Console Buchstabe durch Zahl ersetzen

    Hallo,
    ich möchte in einer Konsolen Anwendung ein Text eingeben und der soll das durch Zahlen/Buchstaben ersetzt werden.
    Und das ganze auch umgekehrt.

    Ich hab es mit Replace gemacht:

    VB.NET-Quellcode

    1. temp = temp.Replace("a", "5")
    2. temp = temp.Replace("b", "9")
    3. temp = temp.Replace("c", "2")
    4. temp = temp.Replace("d", "t")
    5. temp = temp.Replace("e", "w")
    6. temp = temp.Replace("f", "z")
    7. temp = temp.Replace("g", "8")
    8. temp = temp.Replace("h", "i")
    9. temp = temp.Replace("i", "0")
    10. temp = temp.Replace("j", "o")
    11. temp = temp.Replace("k", "j")
    12. temp = temp.Replace("l", "0r")
    13. temp = temp.Replace("m", "9-")
    14. temp = temp.Replace("n", "h")
    15. temp = temp.Replace("o", "1")
    16. temp = temp.Replace("p", "fr")
    17. temp = temp.Replace("q", "s")
    18. temp = temp.Replace("r", "7")
    19. temp = temp.Replace("s", "3")
    20. temp = temp.Replace("t", "6.")
    21. temp = temp.Replace("u", "u")
    22. temp = temp.Replace("v", "d")
    23. temp = temp.Replace("w", "r")
    24. temp = temp.Replace("x", "e")
    25. temp = temp.Replace("y", "a")
    26. temp = temp.Replace("z", "f")
    Ich nehme mal du willst so eine Art "Verschlüssellung" machen. Ist dir eigentlich klar, dass du mit deiner jetzigen Methode die Verschlüsselung nicht mehr rückgängig machen kannst?

    t wird durch 6. ersetzt
    d wird durch t und dann durch 6. ersetzt

    Du darfst jeden Buchstaben nur einmal ersetzen, sonst gehen Eineindeutigkeit und Umkehrbarkeit verloren.