home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 March / PCWorld_2003-03_cd.bin / Software / Vyzkuste / prakticketipyprowindows / soft3_2003.exe / ROT13.VBS < prev    next >
Text File  |  2003-01-20  |  2KB  |  54 lines

  1.  
  2.  
  3. Set oWSHShell = CreateObject("WScript.Shell")
  4. Set oFs = CreateObject("Scripting.FileSystemObject")
  5.  
  6.  
  7. If    Wscript.Arguments.Count = 0 Then
  8.     strInputText = InputBox("Tento skript Üifruje a deÜifruje textovΘ soubory zak≤dovanΘ metodou ROT-13. " & Chr(10) & "P°etßhn∞te textov² soubor na soubor skriptu a v²sledek se vßm ukß₧e v PoznßmkovΘm bloku."& Chr(10) & "DalÜφ mo₧nostφ je zadat text do tohoto polφΦka:","Skript PC WORLDu: ROT-13 En/Decoder")
  9.     If strInputText = "" Then Wscript.Quit
  10.     MsgBox "V²sledek:"& Chr(10) & fROT13(strInputText),0,"Skript PC WORLDu: ROT-13 En/Decoder"
  11.     Wscript.quit
  12. End If
  13.  
  14. strInputDateiPfadundName = Wscript.Arguments(0)
  15. strOutputDateiPfadundName = Replace(oFs.GetParentFolderName(strInputDateiPfadundName) & "\r13_" & oFs.GetFileName(strInputDateiPfadundName), "\\","\")
  16.  
  17. Set oFsInputTextFile = oFs.OpenTextFile(strInputDateiPfadundName,1,False,-2)
  18. Do While oFsInputTextFile.AtEndOfStream <> True
  19.     InputZeilenzahl=InputZeilenzahl+1
  20.     oFsInputTextFile.SkipLine
  21. Loop
  22. oFsInputTextFile.Close
  23.  
  24.  
  25. ReDim Zeile(InputZeilenzahl)
  26. Set oFsInputTextFile = oFs.OpenTextFile(strInputDateiPfadundName,1,False,-2)    
  27. Set oFsOutputTextFile = oFs.CreateTextFile(strOutputDateiPfadundName,True)    
  28.  
  29. oWSHSHell.PopUp "PoΦφtßm...moment prosφm",1,"Blubber",0
  30.  
  31. Do Until oFsInputTextFile.AtEndOfStream = True
  32.     n=n+1
  33.     Zeile(n) = oFsInputTextFile.ReadLine
  34.     oFsOutputTextFile.WriteLine(fROT13(Zeile(n)))
  35.     Set Zeile(n) = Nothing
  36.     Loop
  37. oFsInputTextFile.Close
  38. oFsOutputTextFile.Close
  39.  
  40. oWSHShell.Run "Wordpad " & strOutputDateiPfadundName
  41.  
  42.  
  43. Function fROT13(strString)
  44. Const constAlefBet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
  45.     For lngPos = 1 To Len(strString)
  46.         intChar = Instr(constAlefBet, Mid(strString, lngPos, 1))
  47.         If intChar = 0 Then
  48.             strROT13 = strROT13 & Mid(strString, lngPos, 1)
  49.         Else
  50.             strROT13 = strROT13 & Mid(constAlefBet, intChar + 13, 1)
  51.         End If
  52.     Next
  53.     fROT13 = strROT13
  54. End Function