Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (WSH.Arguments(0) == "code")
- {
- fso = new ActiveXObject("Scripting.FileSystemObject");
- ts = fso.OpenTextFile(WSH.Arguments(1));
- str = ts.ReadAll();
- ts.Close();
- var k = 1;
- output = "";
- for (var i = 0; i < str.length; i++)
- {
- if (str.charAt(i) == str.charAt(i+1))
- k++;
- else
- {
- while (k > 255)
- {
- output += '#' + String.fromCharCode(255) + str.charAt(i);
- k -= 255;
- }
- if (k > 3 || str.charAt(i) == "#")
- output += '#' + String.fromCharCode(k) + str.charAt(i);
- else output += str.substr(i-k+1,k);
- k = 1;
- }
- }
- WSH.echo("Coeff: " + str.length/output.length);
- ts = fso.OpenTextFile(WSH.Arguments(2), 2, true);
- ts.Write(output);
- ts.Close();
- }
- else if (WSH.Arguments(0) == "decode")
- {
- fso = new ActiveXObject("Scripting.FileSystemObject");
- var ts = fso.OpenTextFile(WSH.Arguments(1));
- str = ts.ReadAll();
- ts.Close();
- var output = "";
- for (var i = 0; i < str.length; i++)
- {
- if (str.charAt(i) == "#")
- {
- for (var j = 0; j < str.charCodeAt(i+1); j++)
- output += str.charAt(i+2);
- i += 2;
- }
- else
- {
- output += str.charAt(i);
- }
- }
- ts = fso.OpenTextFile(WSH.Arguments(2), 2, true);
- ts.Write(output);
- ts.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement