//code licensed under DBAD +ROG license
//
http://www.dbad-license.org/package randomizer;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.util.Formatter;
import java.util.Random;
public class main {
public static void main(String[] args) {
try {
byte[] arr = new byte[1000];
byte[] gif;
Random rd = new Random();
//config loading, changing the gif may cause 'unexpected issues'
String[] mcfg = new String(Files.readAllBytes(new File("data\\mainConfig.txt").getCanonicalFile().toPath())).split("\r\n");
int am = Integer.parseInt(mcfg[2].split(": ")[1]); //the 40 can be changed if you want more per run
String outdir = mcfg[3].split(": ")[1];
String[] cfg = new String(Files.readAllBytes(new File("data\\" + mcfg[0].split(": ")[1] + ".txt").getCanonicalFile().toPath())).split("\r\n");
String file = cfg[0].split(": ")[1];
int start = Integer.parseInt(cfg[1].split(": ")[1]);
int end = Integer.parseInt(cfg[2].split(": ")[1]);
for (int i = 0; i < am; i++) {
rd.nextBytes(arr); //create random data
gif = Files.readAllBytes(new File("data\\" + file).getCanonicalFile().toPath());//read file
System.arraycopy(arr, 0, gif, start, end);//copy the random bytes into the gif
byte[] nb = new byte[16];
System.arraycopy(arr, 0, nb, 0, 16);//create a uniue name for the gif
String outname = outdir + "\\";
switch (mcfg[1].split(": ")[1]) {//save file
default:
case "og":
outname += "randomized palate feild_" + b64(nb) + ".gif";
break;
case "skype":
outname += "unknown(" + (i + 1) + ").gif";
break;
case "kym":
outname += (byteToHex(nb[0]) + byteToHex(nb[1])).substring(1) + ".gif";
break;
case "b64":
outname += (b64(nb) + ".gif");
break;
case "twitter":
outname += (b64(nb).substring(0, 16) + ".gif");
break;
case "redditsave":
outname += ("redditsave.com_troonjak_fucking_dies-" + b64(nb).substring(0, 14) + ".mp4.gif");
break;
case "itodler":
outname += Fakeitodlerfilename(nb) + ".gif";
break;
case "trash":
case "trash16":
outname += Garbage(arr, 16) + ".gif";
break;
case "trash32":
outname += Garbage(arr, 32) + ".gif";
break;
}
print("generated: " + outname);
save(outname, gif);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static String Garbage(byte[] inb, int len) { //put the full array in
int bits = byteArrayToIntLE(inb, 32);
String out = "";
char[] b64 = b64(inb).toCharArray();
char[] trash = Lag(inb).toCharArray();
if (len > 500) {
len = 100;
}
for (int i = 0; i < len; i++) {
out += b64[i] + ((bits >> i & 1) == 0 ? byteToHex(inb[i]).toUpperCase() : trash[i] + "");
}
return out;
}
//just a uuid, but seems simple enough no clu what all the seethe is about…
public static String Fakeitodlerfilename(byte[] inb) {
Short pattern = 680;
String out = "";
for (int i = 0; i < 16; i++) {
out += byteToHex(inb[i]) + ((pattern >> i & 1) == 0 ? "" : "-");
}
return out.toUpperCase();
}
public static String b64(byte[] in) {
return Base64.encode(in).replaceAll("\\+", "").replaceAll("/", "").replaceAll("\\=", "");
}
public static String Lag(byte[] in) {
try {
return new String(in, "UTF-16LE");
} catch (UnsupportedEncodingException ex) {
return "null";
}
}
private static String byteToHex(final byte in) {//byte[] hash) {
Formatter formatter = new Formatter();
String result = formatter.format("%02x", in).toString();
formatter.close();
return result;
}
public static int byteArrayToIntLE(byte[] source, int offset) {
int value = 0;
for (int i = 0; i < 4; i++) {
value |= (source[i + offset] & 0x000000FF) << (i * 8);
}
return value;
}
private static void print(Object aThing) {
System.out.println(String.valueOf(aThing));
}
public static void save(String fn, byte[] f) {
try {
Files.write(new File(fn).getCanonicalFile().toPath(), f);
} catch (IOException ex) {
}
}
}