Created
September 3, 2011 16:07
-
-
Save iron9light/1191400 to your computer and use it in GitHub Desktop.
Windows jscript base64 encoder. Drag and drop files you wanna encode to this .js file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fsDoOverwrite = true // Overwrite file with base64 code | |
var fsAsASCII = false // Create base64 code file as ASCII file | |
var adTypeBinary = 1 // Binary file is encoded | |
function encode(from, to) { | |
var inputStream = WScript.CreateObject("ADODB.Stream"); | |
inputStream.Type = adTypeBinary | |
inputStream.Open(); | |
inputStream.LoadFromFile(from); | |
var xml = WScript.CreateObject("MSXml2.DOMDocument"); | |
var element = xml.createElement("Base64Data"); | |
element.dataType = "bin.base64"; | |
element.nodeTypedValue = inputStream.Read(); | |
inputStream.Close(); | |
var fileSystem = WScript.CreateObject("Scripting.FileSystemObject"); | |
var outputStream = fileSystem.CreateTextFile(to, fsDoOverwrite, fsAsASCII); | |
outputStream.Write(element.text.replace(/\n/g, "")); | |
outputStream.Close(); | |
} | |
function getTxtName(name) { | |
return name + ".txt"; | |
} | |
function main() { | |
var args = WScript.Arguments; | |
for(i = 0; i < args.length; ++i) { | |
encode(args(i), getTxtName(args(i))); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment