Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Comments left by u/Maxxer500, aka C0deR0gue
- 'Comments left to explain what parts are broken/causing undesirable effects, and why
- 'Fixes will be demonstrated in comments along with explanations
- 'The sheer number of empty space in here makes reading this script much more difficult than it has to be. You can bunch related bits together!
- 'There's some unnecessary bits here making things less readable, and the new line breaks things. That might've been Reddit doing weird formatting
- 'Set x = CreateObject("wscript.shell")
- set x = WScript.CreateObject("
- WScript.Shell")
- encrypt = inputbox("type text om te versleutelen")
- 'This line is completely fine, but as mentioned in my "simple 2-way cipher.vbs" uppercase characters won't be picked up by the Replace function and won't be converted. It's fine if that's intentional, but if it isn't just add the following line:
- 'encrypt=lcase(encrypt)
- encrypt = StrReverse(encrypt)
- x.Run "%windir%\notepad"
- wscript.sleep 1000
- 'In this line you call the encode function, but it hasn't been defined yet! I don't recall if VBScript breaks in this scenario, but I know other coding/scripting languages will. Simply put this line after the "End Function" line
- x.sendkeys encode(encrypt)
- function encode(s)
- 'From what I can tell this line is unnecessary and iterates the text 25 times
- For counter = 1 To 25 Step 1
- 'The Replace function works on every part of the string by default, so there's no need to run it multiple times
- For i = 1 To Len(s)
- 'I'm confused what the purpose of this line is, and I'm pretty sure it complicates things
- newtxt = Mid(s, i, 1)
- 'Okay this upcoming section has a number of issues. For one, it converts both C and I into N, and N converts to L. There's also a couple characters that don't get converted into, like C. If this is supposed to work 2-ways, each character can only have one corresponding character and corresponding characters need to link back to each other.
- 'For a fixed version you can refer to the "simple 2-way cipher.vbs" I'm linking in addition to this script, just look at the cipher function there
- newtxt = Replace(newtxt,"a", "w")
- newtxt = Replace(newtxt,"b", "j")
- newtxt = Replace(newtxt,"c", "n")
- newtxt = Replace(newtxt,"d", "s")
- newtxt = Replace(newtxt,"e", "z")
- newtxt = Replace(newtxt,"f", "g")
- newtxt = Replace(newtxt,"g", "q")
- newtxt = Replace(newtxt,"h", "m")
- newtxt = Replace(newtxt,"i", "n")
- newtxt = Replace(newtxt,"j", "a")
- newtxt = Replace(newtxt,"k", "f")
- newtxt = Replace(newtxt,"l", "u")
- newtxt = Replace(newtxt,"m", "o")
- newtxt = Replace(newtxt,"n", "l")
- newtxt = Replace(newtxt,"o", "d")
- newtxt = Replace(newtxt,"p", "h")
- newtxt = Replace(newtxt,"q", "@")
- newtxt = Replace(newtxt,"r", "#")
- 'The carot (^) symbol has a special use in the SendKeys function, so while it won't break here it will cause undesired effects in the text when typed. I believe this can be fixed by encasing it in braces
- 'More info at: https://docs.microsoft.com/en-us/office/vba/Language/Reference/user-interface-help/sendkeys-statement
- 'newtxt=Replace(newtxt , "s" , "{^}")
- newtxt = Replace(newtxt,"s", "^")
- 'Same issue as the carot, encase it in braces
- 'newtxt=Replace(newtxt , "t" , "{%}")
- newtxt = Replace(newtxt,"t", "%")
- newtxt = Replace(newtxt,"u", "€")
- 'Same issue as the carot, encase it in braces
- 'newtxt=Replace(newtxt, "v" , "{~}")
- newtxt = Replace(newtxt,"v", "~")
- newtxt = Replace(newtxt,"w", "&")
- newtxt = Replace(newtxt,"x", "$")
- newtxt = Replace(newtxt,"y", "!")
- newtxt = Replace(newtxt,"z", "e")
- 'This line right here. This line is what gives you the weird characters that aren't seen anywhere in the script. I believe the & is combining things in some mathematical way, instead of as text. And it's not even necessary! Just output your newtxt variable and things will work.
- coded = coded & newtxt
- 'You have 2 For statements above, but only 1 Next. VBScript kept yelling at me for 20 minutes until I gave it another Next. But we're removing the For statements, so remove the Next statements as well
- Next
- 'After removing the "coded = coded & newtxt" line you need to change coded to newtxt in this line
- 'encode=newtxt
- encode = coded
- End function
Advertisement
Add Comment
Please, Sign In to add comment