5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -16,5 +16,10 @@
|
|||||||
<option name="name" value="MavenRepo" />
|
<option name="name" value="MavenRepo" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://nexus.stirante.com/repository/maven-snapshots/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
28
README.md
28
README.md
@@ -53,6 +53,34 @@ Make sure you have Java 17 or higher installed on your system!
|
|||||||
3. Build with gradle `$ ./gradlew build`
|
3. Build with gradle `$ ./gradlew build`
|
||||||
4. Build will be output to `/Countroll/build/libs`
|
4. Build will be output to `/Countroll/build/libs`
|
||||||
|
|
||||||
|
# Config With Comments
|
||||||
|
|
||||||
|
```json
|
||||||
|
{ // The config is in json, there are no comments allowed in the countroll.json
|
||||||
|
"doCopy": false, // Automaticaly copying to clipboard
|
||||||
|
"deep": false, // Deep obfuscation, doubling output size
|
||||||
|
"verbose.errors": true, // Error printing
|
||||||
|
"color": true, // Razor Chroma RGB xpressions are outputed
|
||||||
|
"useRoot": true, // Uses sqrt() function
|
||||||
|
"verbose.complexers": false, // Shows what the complexers are doing
|
||||||
|
"show.progress": false, // Shows the current eval as the expression is building
|
||||||
|
"useDivide": true, // Toggles the divide complexer
|
||||||
|
"verbose.eval": false, // Shows what the eval function is doing
|
||||||
|
"verbose.processes": true, // Shows non looping verbose
|
||||||
|
"printHelp": false, // Prints a help message then exits
|
||||||
|
"mode": "U", // Switch modes
|
||||||
|
// U is universal, and will follow all the comlpexer toggles for fully custom setup
|
||||||
|
// D is duckgroup mode, and will not use lettered functions
|
||||||
|
// N is numselli mode, and will enable all complexers
|
||||||
|
"verbose.all": false, // Shows all the verbose
|
||||||
|
"usePower": true, // Toggles power complexer
|
||||||
|
"useModDividend": true, // Toggles moduRootDividend complexer (doesnt use letters)
|
||||||
|
"verbose.utils": false, // Shows what the Utils are doing
|
||||||
|
"verbose.increasers": false, // Shows what the increasers are doing
|
||||||
|
"verbose.loops": false // Shows what the loops are doing
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# Up Next
|
# Up Next
|
||||||
Development will continue with the addition of bitwise operations AND (&) and OR (|)
|
Development will continue with the addition of bitwise operations AND (&) and OR (|)
|
||||||
- Both bots support these operators, and it will be in both modes
|
- Both bots support these operators, and it will be in both modes
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ version '0.0.4'
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url 'https://nexus.stirante.com/repository/maven-snapshots/'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'net.objecthunter:exp4j:0.4.8'
|
implementation 'net.objecthunter:exp4j:0.4.8'
|
||||||
implementation 'com.ezylang:EvalEx:3.0.5'
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||||
}
|
}
|
||||||
@@ -22,7 +25,7 @@ test {
|
|||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes 'Main-Class': 'me.trouper.Main'
|
attributes 'Main-Class': 'me.trouper.Countroll'
|
||||||
}
|
}
|
||||||
from {
|
from {
|
||||||
configurations.runtimeClasspath.collect {
|
configurations.runtimeClasspath.collect {
|
||||||
|
|||||||
182
src/main/java/me/trouper/Countroll.java
Normal file
182
src/main/java/me/trouper/Countroll.java
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
package me.trouper;
|
||||||
|
|
||||||
|
import me.trouper.Data.ConfigManager;
|
||||||
|
import me.trouper.Functions.Complexers;
|
||||||
|
import me.trouper.Functions.Obf;
|
||||||
|
import me.trouper.Utils.Timer;
|
||||||
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import static me.trouper.Functions.Eval.eval;
|
||||||
|
import static me.trouper.Utils.Utils.copyToClip;
|
||||||
|
import static me.trouper.Utils.Utils.removeColors;
|
||||||
|
|
||||||
|
public class Countroll {
|
||||||
|
public static boolean showProgress;
|
||||||
|
public static boolean doCopy;
|
||||||
|
public static boolean deep;
|
||||||
|
public static boolean color;
|
||||||
|
public static boolean printHelp;
|
||||||
|
public static String mode;
|
||||||
|
|
||||||
|
/* Statistics */
|
||||||
|
public static int errorCount = 0;
|
||||||
|
public static int expCount = 0;
|
||||||
|
public static int factorCount = 0;
|
||||||
|
public static int addCount = 0;
|
||||||
|
public static int subCount = 0;
|
||||||
|
public static int divideCount = 0;
|
||||||
|
public static int powerCount = 0;
|
||||||
|
public static int rDivisorCount = 0;
|
||||||
|
public static int rDividendCount = 0;
|
||||||
|
public static int rootCount = 0;
|
||||||
|
public static int perfectCount = 0;
|
||||||
|
public static int total = 0;
|
||||||
|
public static void clearStats() {
|
||||||
|
expCount = 0;
|
||||||
|
factorCount = 0;
|
||||||
|
addCount = 0;
|
||||||
|
subCount = 0;
|
||||||
|
divideCount = 0;
|
||||||
|
powerCount = 0;
|
||||||
|
rDivisorCount = 0;
|
||||||
|
rDividendCount = 0;
|
||||||
|
rootCount = 0;
|
||||||
|
perfectCount = 0;
|
||||||
|
total = 0;
|
||||||
|
errorCount = 0;
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
ConfigManager.loadConfig();
|
||||||
|
|
||||||
|
parseCommandLineArguments(args);
|
||||||
|
|
||||||
|
Verbose.send("INIT", "Loading config");
|
||||||
|
Verbose.send("INIT", "Config loaded, mode: " + mode);
|
||||||
|
|
||||||
|
if (mode.equals("D")) {
|
||||||
|
Complexers.useRoot = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode.equals("TEST")) {
|
||||||
|
handleTestMode(scanner);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printHelp) {
|
||||||
|
Utils.printHelp();
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
if (color) {
|
||||||
|
Utils.printColorKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
handleTargetIntegers(scanner);
|
||||||
|
scanner.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void parseCommandLineArguments(String[] args) {
|
||||||
|
for (String arg : args) {
|
||||||
|
switch (arg) {
|
||||||
|
case "--copy", "-c" -> doCopy = true;
|
||||||
|
case "--verbose", "-v" -> Verbose.all = true;
|
||||||
|
case "--deep", "-d" -> deep = true;
|
||||||
|
case "--color", "-rgb" -> color = true;
|
||||||
|
case "--help", "--h", "-h" -> printHelp = true;
|
||||||
|
case "--mode=test", "-m=t" -> mode = "TEST";
|
||||||
|
case "--mode=duckgroup", "-m=d" -> mode = "D";
|
||||||
|
case "--mode=numselli", "-m=n" -> mode = "N";
|
||||||
|
case "--mode=universal", "-m=u" -> mode = "U";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleTestMode(Scanner scanner) {
|
||||||
|
while (true) {
|
||||||
|
System.out.print("Enter an expression (or 'exit' to exit): ");
|
||||||
|
String userInput = scanner.next();
|
||||||
|
|
||||||
|
if (userInput.equals("exit")) {
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
double result = eval(userInput);
|
||||||
|
System.out.println("Result: " + result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Error: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleTargetIntegers(Scanner scanner) {
|
||||||
|
while (true) {
|
||||||
|
System.out.print("Enter Target Integer: ");
|
||||||
|
if (scanner.hasNextInt()) {
|
||||||
|
int target = scanner.nextInt();
|
||||||
|
|
||||||
|
Timer obfTimer = Timer.start();
|
||||||
|
String expression = Obf.obfInt(target);
|
||||||
|
long obfTime = obfTimer.end().timePassed();
|
||||||
|
|
||||||
|
double output = eval(removeColors(expression));
|
||||||
|
|
||||||
|
printStatistics(obfTime);
|
||||||
|
printReport(target,expression,output);
|
||||||
|
if (doCopy) copyToClip(removeColors(expression));
|
||||||
|
} else {
|
||||||
|
System.out.println("Exiting the program.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void printReport(int target, String expression, double output) {
|
||||||
|
String report;
|
||||||
|
if (target == output) {
|
||||||
|
report = String.format("""
|
||||||
|
╔═══════[ Report ]═════════
|
||||||
|
║ Target Integer: %d
|
||||||
|
║ Final Result: %s <&ah><&b>✔<&r>
|
||||||
|
║ Expression Length: %s
|
||||||
|
╚══════════════════════════
|
||||||
|
|
||||||
|
>> %s
|
||||||
|
""",target,output,expression.length(),expression);
|
||||||
|
} else {
|
||||||
|
report = String.format("""
|
||||||
|
╔═══════[ Report ]═════════
|
||||||
|
║ Target Integer: %d
|
||||||
|
║ Final Result: %s <&ch><&e>❌<&r>
|
||||||
|
║ Expression Length: %s
|
||||||
|
╚══════════════════════════
|
||||||
|
|
||||||
|
>> %s
|
||||||
|
""",target,output,expression.length(),expression);
|
||||||
|
}
|
||||||
|
System.out.println((color) ? Utils.activateColors(report) : removeColors(report));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printStatistics(long time) {
|
||||||
|
String statistics = String.format("""
|
||||||
|
|
||||||
|
╔═══════[ Statistics ]═════════
|
||||||
|
║ Exponents: %d
|
||||||
|
║ Factors: %d
|
||||||
|
║ Additions: %d
|
||||||
|
║ Subtractions: %d
|
||||||
|
║ Divisors: %d
|
||||||
|
║ Powers: %d
|
||||||
|
║ mRootDividends: %d
|
||||||
|
║ Roots Taken: %d
|
||||||
|
║ Perfect Squares Found: %d
|
||||||
|
║ Errors: %d
|
||||||
|
╠══════════════════════════════
|
||||||
|
║ Total steps taken: %d
|
||||||
|
║ Elapsed Time: %d
|
||||||
|
╚══════════════════════════════
|
||||||
|
""", expCount, factorCount, addCount, subCount, divideCount, powerCount, rDividendCount, rootCount, perfectCount, errorCount, total, time);
|
||||||
|
System.out.println(statistics);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
src/main/java/me/trouper/Data/ConfigManager.java
Normal file
87
src/main/java/me/trouper/Data/ConfigManager.java
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
package me.trouper.Data;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonIOException;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Functions.Complexers;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConfigManager {
|
||||||
|
private static final String CONFIG_FILENAME = "countroll.json";
|
||||||
|
|
||||||
|
public static void loadConfig() {
|
||||||
|
File configFile = new File(CONFIG_FILENAME);
|
||||||
|
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
generateDefaultConfig();
|
||||||
|
} else {
|
||||||
|
try (Reader reader = new FileReader(configFile)) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Map<String, Object> config = gson.fromJson(reader, HashMap.class);
|
||||||
|
getConfig(config);
|
||||||
|
} catch (JsonSyntaxException | JsonIOException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
generateDefaultConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void generateDefaultConfig() {
|
||||||
|
Map<String, Object> defaultConfig = new HashMap<>();
|
||||||
|
defaultConfig.put("useDivide", true);
|
||||||
|
defaultConfig.put("usePower", true);
|
||||||
|
defaultConfig.put("useRoot", true);
|
||||||
|
defaultConfig.put("useModDividend", true);
|
||||||
|
defaultConfig.put("doCopy", false);
|
||||||
|
defaultConfig.put("deep", false);
|
||||||
|
defaultConfig.put("color", true);
|
||||||
|
defaultConfig.put("printHelp", false);
|
||||||
|
defaultConfig.put("mode", "U");
|
||||||
|
defaultConfig.put("show.progress", false);
|
||||||
|
defaultConfig.put("verbose.all",false);
|
||||||
|
defaultConfig.put("verbose.processes",true);
|
||||||
|
defaultConfig.put("verbose.loops",false);
|
||||||
|
defaultConfig.put("verbose.eval",false);
|
||||||
|
defaultConfig.put("verbose.complexers",false);
|
||||||
|
defaultConfig.put("verbose.increasers",false);
|
||||||
|
defaultConfig.put("verbose.utils",false);
|
||||||
|
defaultConfig.put("verbose.errors",true);
|
||||||
|
|
||||||
|
try (Writer writer = new FileWriter(CONFIG_FILENAME)) {
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
gson.toJson(defaultConfig, writer);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
getConfig(defaultConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getConfig(Map<String, Object> config) {
|
||||||
|
Verbose.send("INIT", "Loading main class variables");
|
||||||
|
Complexers.useDivide = (boolean) config.get("useDivide");
|
||||||
|
Complexers.usePower = (boolean) config.get("usePower");
|
||||||
|
Complexers.useRoot = (boolean) config.get("useRoot");
|
||||||
|
Complexers.useRDividend = (boolean) config.get("useModDividend");
|
||||||
|
Countroll.showProgress = (boolean) config.get("show.progress");
|
||||||
|
Countroll.doCopy = (boolean) config.get("doCopy");
|
||||||
|
Countroll.deep = (boolean) config.get("deep");
|
||||||
|
Countroll.color = (boolean) config.get("color");
|
||||||
|
Countroll.printHelp = (boolean) config.get("printHelp");
|
||||||
|
Countroll.mode = (String) config.get("mode");
|
||||||
|
Verbose.all = (boolean) config.get("verbose.all");
|
||||||
|
Verbose.processes = (boolean) config.get("verbose.processes");
|
||||||
|
Verbose.loops = (boolean) config.get("verbose.loops");
|
||||||
|
Verbose.eval = (boolean) config.get("verbose.eval");
|
||||||
|
Verbose.complexers = (boolean) config.get("verbose.complexers");
|
||||||
|
Verbose.increasers = (boolean) config.get("verbose.increasers");
|
||||||
|
Verbose.utils = (boolean) config.get("verbose.utils");
|
||||||
|
Verbose.errors = (boolean) config.get("verbose.errors");
|
||||||
|
Verbose.send("INIT","mode = " + Countroll.mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
import me.trouper.Utils.Utils;
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -14,7 +15,6 @@ public class Complexers {
|
|||||||
public static boolean usePower;
|
public static boolean usePower;
|
||||||
public static boolean useRoot;
|
public static boolean useRoot;
|
||||||
public static boolean useRDividend;
|
public static boolean useRDividend;
|
||||||
public static boolean useRDivisor;
|
|
||||||
|
|
||||||
public static String pickComplexer() {
|
public static String pickComplexer() {
|
||||||
List<String> enabledComplexers = new ArrayList<>();
|
List<String> enabledComplexers = new ArrayList<>();
|
||||||
@@ -23,7 +23,6 @@ public class Complexers {
|
|||||||
if (usePower) enabledComplexers.add("power");
|
if (usePower) enabledComplexers.add("power");
|
||||||
if (useRoot) enabledComplexers.add("root");
|
if (useRoot) enabledComplexers.add("root");
|
||||||
if (useRDividend) enabledComplexers.add("mrDividend");
|
if (useRDividend) enabledComplexers.add("mrDividend");
|
||||||
if (useRDivisor) enabledComplexers.add("mrDivisor");
|
|
||||||
|
|
||||||
Collections.shuffle(enabledComplexers);
|
Collections.shuffle(enabledComplexers);
|
||||||
if (!enabledComplexers.isEmpty()) {
|
if (!enabledComplexers.isEmpty()) {
|
||||||
@@ -40,6 +39,9 @@ public class Complexers {
|
|||||||
return divide(i,deep);
|
return divide(i,deep);
|
||||||
}
|
}
|
||||||
case "power" -> {
|
case "power" -> {
|
||||||
|
if (!isPerfectSquare(i)) {
|
||||||
|
return divide(i,deep);
|
||||||
|
}
|
||||||
return power(i,deep);
|
return power(i,deep);
|
||||||
}
|
}
|
||||||
case "root" -> {
|
case "root" -> {
|
||||||
@@ -48,9 +50,6 @@ public class Complexers {
|
|||||||
case "mrDividend" -> {
|
case "mrDividend" -> {
|
||||||
return mRootDividend(i,deep);
|
return mRootDividend(i,deep);
|
||||||
}
|
}
|
||||||
case "mrDivisor" -> {
|
|
||||||
return mRootDivisor(i,deep);
|
|
||||||
}
|
|
||||||
default -> {
|
default -> {
|
||||||
return divide(i,false);
|
return divide(i,false);
|
||||||
}
|
}
|
||||||
@@ -62,21 +61,20 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String divide(int i, boolean deep) {
|
public static String divide(int i, boolean deep) {
|
||||||
Main.divideCount++;
|
Verbose.send("COMP", "Running Divide Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.divideCount++;
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int factor = random.nextInt(9)+1;
|
int factor = random.nextInt(9)+1;
|
||||||
int doubled = i * factor;
|
int doubled = i * factor;
|
||||||
boolean expFac = false;
|
|
||||||
boolean expDoub = false;
|
|
||||||
|
|
||||||
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
|
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&3>(<&r><&d>" + (complex(doubled,false)) + "<&b>/<&r><&d>" + (complex(factor,false)) + "<&3>)<&r>";
|
result = "<&3>(<&r><&d>" + (complex(doubled,false)) + "<&b>/<&r><&d>" + (complex(factor,false)) + "<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("Failed to divide " + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to divide <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return eval(result) == i ? result : "(" + i + ")";
|
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,10 +84,8 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String power(int i, boolean deep) {
|
public static String power(int i, boolean deep) {
|
||||||
Main.powerCount++;
|
Verbose.send("COMP", "Running Power Complexer, I:" + i + " Deep: " + deep);
|
||||||
if (!Eval.isPerfectSquare(i)) {
|
Countroll.powerCount++;
|
||||||
return "(" + i + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
int root = (int) Math.sqrt(i);
|
int root = (int) Math.sqrt(i);
|
||||||
String result = "<&r><&f>(<&e>" + root + "<&b>^<&e>2<&f>)<&r>";
|
String result = "<&r><&f>(<&e>" + root + "<&b>^<&e>2<&f>)<&r>";
|
||||||
@@ -97,8 +93,8 @@ public class Complexers {
|
|||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&r><&3>(<&d>" + complex(root,false) + "<&b>^<&d>2<&3>)<&r>";
|
result = "<&r><&3>(<&d>" + complex(root,false) + "<&b>^<&d>2<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to power <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to power <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return eval(result) == i ? result : "(" + i + ")";
|
return eval(result) == i ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,39 +103,16 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String root(int i, boolean deep) {
|
public static String root(int i, boolean deep) {
|
||||||
Main.rootCount++;
|
Verbose.send("COMP", "Running Root Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.rootCount++;
|
||||||
int squared = (int) Math.pow(i,2);
|
int squared = (int) Math.pow(i,2);
|
||||||
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
|
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&1>sqrt<&r><&3>(<&r><&d>" + complex(squared, false) + "<&3>)<&r>";
|
result = "<&1>sqrt<&r><&3>(<&r><&d>" + complex(squared, false) + "<&3>)<&r>";
|
||||||
}
|
}
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to root <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to root <&r>" + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses modulus (ri%divisor)=i
|
|
||||||
* @param i Modulus to return
|
|
||||||
* @return Colored string
|
|
||||||
*/
|
|
||||||
public static String mRootDivisor(int i, boolean deep) {
|
|
||||||
Main.rDivisorCount++;
|
|
||||||
Random random = new Random();
|
|
||||||
int dividend = random.nextInt(9)+i+10;
|
|
||||||
int divisor = Utils.moduRootDivisor(dividend,i);
|
|
||||||
String result = "<&r><&f>(<&e>" + dividend + "<&b>%<&e>" + divisor + "<&f>)<&r>";
|
|
||||||
if (deep) {
|
|
||||||
result = "<&r><&7>(<&d>" + complex(dividend,false) + "<&b>%<&d>" + complex(divisor, false) + "<&7>)<&r>";
|
|
||||||
}
|
|
||||||
Utils.verbose("<&dh><&b>mRootDivisor has ran!<&r>" +
|
|
||||||
"\nWanted: " + i +
|
|
||||||
"\nDivisor: " + divisor +
|
|
||||||
"\nDividend: " + dividend +
|
|
||||||
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
|
||||||
"\nResult: " + result);
|
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to mRootDivisor<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +121,8 @@ public class Complexers {
|
|||||||
* @return Colored String
|
* @return Colored String
|
||||||
*/
|
*/
|
||||||
public static String mRootDividend(int i, boolean deep) {
|
public static String mRootDividend(int i, boolean deep) {
|
||||||
Main.rDividendCount++;
|
Verbose.send("COMP", "Running mrDividend Complexer, I:" + i + " Deep: " + deep);
|
||||||
|
Countroll.rDividendCount++;
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int divisor = random.nextInt(9)+i+10;
|
int divisor = random.nextInt(9)+i+10;
|
||||||
int dividend = Utils.moduRootDividend(divisor,i);
|
int dividend = Utils.moduRootDividend(divisor,i);
|
||||||
@@ -156,14 +130,14 @@ public class Complexers {
|
|||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&r><&7>(<&d>" + complex(dividend,false) + "<&b>%<&d>" + complex(divisor,false) + "<&7>)<&r>";
|
result = "<&r><&7>(<&d>" + complex(dividend,false) + "<&b>%<&d>" + complex(divisor,false) + "<&7>)<&r>";
|
||||||
}
|
}
|
||||||
Utils.verbose("<&dh><&b>mRootDividend has been ran!<&r>" +
|
Verbose.send("COMP","<&dh><&b>mRootDividend has been ran!<&r>" +
|
||||||
"\nWanted:" + i +
|
"\nWanted:" + i +
|
||||||
"\nDivisor: " + divisor +
|
"\nDivisor: " + divisor +
|
||||||
"\nDividend: " + dividend +
|
"\nDividend: " + dividend +
|
||||||
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
"\nCheck: " + dividend + "%" + divisor + "=" + i +
|
||||||
"\nResult: " + result);
|
"\nResult: " + result);
|
||||||
if (eval(result) != i) Utils.verbose("<&ch>Failed to mRootDividend<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
if (eval(result) != i) Verbose.send("ERR","<&ch>Failed to mRootDividend<&r> " + i + ", Attempted: " + result + "=" + eval(result));
|
||||||
return (eval(result) == i) ? result : "(" + i + ")";
|
return (eval(result) == i) ? result : "<&ch>(" + i + ")<&r>";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,23 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import com.ezylang.evalex.EvaluationException;
|
|
||||||
import com.ezylang.evalex.data.EvaluationValue;
|
|
||||||
import com.ezylang.evalex.parser.ParseException;
|
|
||||||
import me.trouper.Utils.Utils;
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
import net.objecthunter.exp4j.Expression;
|
import net.objecthunter.exp4j.Expression;
|
||||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||||
|
|
||||||
public class Eval {
|
public class Eval {
|
||||||
public static double eval(String expression) {
|
public static double eval(String expression) {
|
||||||
final String cleaned = Utils.removeColors(expression);
|
final String cleaned = Utils.removeColors(expression);
|
||||||
Utils.verbose("Evaluating Expression: " + cleaned);
|
Verbose.send("EVAL","Evaluating Expression: " + cleaned);
|
||||||
Expression exp = new ExpressionBuilder(cleaned).build();
|
Expression exp = new ExpressionBuilder(cleaned).build();
|
||||||
return exp.evaluate();
|
return exp.evaluate();
|
||||||
}
|
}
|
||||||
public static boolean isPerfectSquare(int num) {
|
public static boolean isPerfectSquare(int num) {
|
||||||
if (num < 0) {
|
if (num == 0) return false;
|
||||||
return false;
|
final double sq = Math.sqrt(num);
|
||||||
}
|
return sq == Math.floor(sq);
|
||||||
int sqrt = (int) Math.sqrt(num);
|
|
||||||
return sqrt * sqrt == num;
|
|
||||||
}
|
}
|
||||||
public static boolean isInt(double number) {
|
public static boolean isInt(double number) {
|
||||||
return (number == Math.floor(number)) && !Double.isInfinite(number);
|
return (number == Math.floor(number)) && !Double.isInfinite(number);
|
||||||
}
|
}
|
||||||
public static double evalM(String exp) throws EvaluationException, ParseException {
|
|
||||||
com.ezylang.evalex.Expression expression = new com.ezylang.evalex.Expression(exp);
|
|
||||||
EvaluationValue result = expression.evaluate();
|
|
||||||
return result.getNumberValue().doubleValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,69 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Utils.Utils;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static me.trouper.Functions.Eval.eval;
|
import static me.trouper.Functions.Eval.eval;
|
||||||
import static me.trouper.Functions.Eval.isPerfectSquare;
|
import static me.trouper.Functions.Eval.isPerfectSquare;
|
||||||
|
|
||||||
public class Increasers {
|
public class Increasers {
|
||||||
public static String multiply(int i, int factor, boolean deep) {
|
|
||||||
boolean useExp = isPerfectSquare(i);
|
|
||||||
|
|
||||||
String result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
public static String increase(int current, int target, int i, boolean deep) {
|
||||||
|
if (target - current > 64000) {
|
||||||
|
Countroll.expCount++;
|
||||||
|
return Increasers.power(i,4,deep);
|
||||||
|
} else if (target - current > 4069) {
|
||||||
|
Countroll.expCount++;
|
||||||
|
return Increasers.power(i,3,deep);
|
||||||
|
} else if (target - current > 1048) {
|
||||||
|
Countroll.expCount++;
|
||||||
|
return Increasers.power(i,2,deep);
|
||||||
|
} else if (target - current > 128) {
|
||||||
|
Countroll.factorCount++;
|
||||||
|
return Increasers.multiply(i,9,deep);
|
||||||
|
} else {
|
||||||
|
return multiply(i,2,deep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static String multiply(int i, int factor, boolean deep) {
|
||||||
|
Countroll.factorCount++;
|
||||||
|
String result;
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&7>(<&r><&2>" + (useExp ? Complexers.power(i,true) : Complexers.divide(i,true)) + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
result = "<&7>(<&r><&2>" + (Complexers.complex(i,true)) + "<&b>*<&r><&2>" + Complexers.complex(i,true) + "<&7>)<&r>";
|
||||||
|
if (eval(result) == i * factor) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return eval(result) == i * factor ? result : "(" + i + ")";
|
result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
||||||
|
double calc = eval(result);
|
||||||
|
|
||||||
|
if (!(calc == Math.multiplyExact(i,factor))) Verbose.send("ERR", "Failed multiply increaser! " +
|
||||||
|
"\nAttempted expression: " + result +
|
||||||
|
"\nTarget: " + i +
|
||||||
|
"\nCalc: " + calc);
|
||||||
|
return calc == i * factor ? result : "(" + i + ")";
|
||||||
}
|
}
|
||||||
public static String power(int i, int exp, boolean deep) {
|
public static String power(int i, int exp, boolean deep) {
|
||||||
boolean useExp = isPerfectSquare(i);
|
Countroll.powerCount++;
|
||||||
|
String result;
|
||||||
String result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
result = "<&7>(<&r><&2>" + (useExp ? Complexers.power(i,true) : Complexers.divide(i,true)) + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
result = "<&7>(<&r><&2>" + Complexers.complex(i,true) + "<&b>^<&r><&2>" + Complexers.complex(i,true) + "<&7>)<&r>";
|
||||||
|
if (eval(result) == Math.pow(i,exp)) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return eval(result) == Math.pow(i,exp) ? result : "(" + i + ")";
|
result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
||||||
|
double calc = eval(result);
|
||||||
|
|
||||||
|
if (!(calc == Math.pow(i,exp))) Verbose.send("ERR", "Failed multiply increaser! " +
|
||||||
|
"\nAttempted expression: " + result +
|
||||||
|
"\nTarget: " + i +
|
||||||
|
"\nCalc: " + calc);
|
||||||
|
return calc == Math.pow(i,exp) ? result : "(" + i + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,64 @@
|
|||||||
package me.trouper.Functions;
|
package me.trouper.Functions;
|
||||||
|
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Utils.Verbose;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static me.trouper.Functions.Eval.*;
|
import static me.trouper.Functions.Eval.*;
|
||||||
import static me.trouper.Functions.Eval.eval;
|
import static me.trouper.Functions.Eval.eval;
|
||||||
import static me.trouper.Utils.Utils.removeColors;
|
import static me.trouper.Utils.Utils.removeColors;
|
||||||
import static me.trouper.Utils.Utils.verbose;
|
|
||||||
|
|
||||||
public class Obf {
|
public class Obf {
|
||||||
|
public static String obfInt(int target) {
|
||||||
|
Verbose.send("PROC", "Starting Obfuscation (Universal)");
|
||||||
|
StringBuilder expression = new StringBuilder();
|
||||||
|
Random rand = new Random();
|
||||||
|
|
||||||
|
// INIT
|
||||||
|
int init = rand.nextInt(9)+1;
|
||||||
|
Verbose.send("PROC", "Initializing Expression: " + init);
|
||||||
|
expression.append("<&dh><&f>").append(init).append("<&r>");
|
||||||
|
|
||||||
|
// MAIN LOOP
|
||||||
|
Verbose.send("PROC", "Beginning Main Loop: ");
|
||||||
|
while (eval(expression.toString()) != target) {
|
||||||
|
Countroll.total++;
|
||||||
|
int current = (int) eval(expression.toString());
|
||||||
|
int ri = rand.nextInt(9)+1;
|
||||||
|
if (Countroll.showProgress) System.out.println("Current Evaluation: " + current);
|
||||||
|
|
||||||
|
// Checking for it still being a whole number
|
||||||
|
if (!isInt(eval(expression.toString()))) {
|
||||||
|
System.out.println("Something went horribly wrong, Here is the relevant info." +
|
||||||
|
"\nEvaluation: " + eval(expression.toString()) +
|
||||||
|
"\nRandom Pick: " + ri +
|
||||||
|
"\nCaught at: \n" + removeColors(expression.toString()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String comp = Complexers.complex(ri,Countroll.deep);
|
||||||
|
// Case for if its below
|
||||||
|
if (current < target) {
|
||||||
|
Countroll.addCount++;
|
||||||
|
expression.append("<&b>+<&r><&e>").append(comp).append("<&r>");
|
||||||
|
if (target - current > 128) {
|
||||||
|
expression.append("<&b>*<&r><&e>").append(Increasers.increase(current,target,ri,Countroll.deep)).append("<&r>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case for if its above
|
||||||
|
if (current > target) {
|
||||||
|
Countroll.subCount++;
|
||||||
|
expression.append("<&b>-<&r><&e>").append(comp).append("<&r>");
|
||||||
|
if (current - target > 128) {
|
||||||
|
expression.append("<&b>-<&r><&e>").append(Increasers.increase(target,current,ri,Countroll.deep)).append("<&r>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Verbose.send("PROC", "Broke out of loop.");
|
||||||
|
return expression.toString();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* ObfIntN will work for Numselli's counting bot
|
* ObfIntN will work for Numselli's counting bot
|
||||||
* @param target Integer to reach
|
* @param target Integer to reach
|
||||||
@@ -23,12 +72,12 @@ public class Obf {
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int initializer = random.nextInt(9)+1;
|
int initializer = random.nextInt(9)+1;
|
||||||
verbose("Initializing Expression: " + initializer);
|
Verbose.send("PROC","Initializing Expression: " + initializer);
|
||||||
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
||||||
|
|
||||||
|
|
||||||
while (eval(expression.toString()) != target) {
|
while (eval(expression.toString()) != target) {
|
||||||
Main.total++;
|
Countroll.total++;
|
||||||
int eval = (int) eval(expression.toString());
|
int eval = (int) eval(expression.toString());
|
||||||
int ri = random.nextInt(9)+1;
|
int ri = random.nextInt(9)+1;
|
||||||
int op = random.nextInt(2);
|
int op = random.nextInt(2);
|
||||||
@@ -43,12 +92,12 @@ public class Obf {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("Random: " + ri);
|
Verbose.send("LOOP","Random: " + ri);
|
||||||
verbose("Current: " + eval(expression.toString()));
|
Verbose.send("LOOP","Current: " + eval(expression.toString()));
|
||||||
|
|
||||||
if (isPerfectSquare(eval) && eval != 1) {
|
if (isPerfectSquare(eval) && eval != 1) {
|
||||||
Main.perfectCount++;
|
Countroll.perfectCount++;
|
||||||
verbose("PERFECT SQUARE TIME! (" + Main.perfectCount+ ")");
|
Verbose.send("LOOP","PERFECT SQUARE TIME! (" + Countroll.perfectCount+ ")");
|
||||||
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
|
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
|
||||||
eval = (int) eval(expression.toString());
|
eval = (int) eval(expression.toString());
|
||||||
}
|
}
|
||||||
@@ -57,34 +106,34 @@ public class Obf {
|
|||||||
|
|
||||||
if (eval < target) {
|
if (eval < target) {
|
||||||
if (target - eval > 4069) {
|
if (target - eval > 4069) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
verbose("Large than (" + Main.expCount + ")");
|
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,3,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,3,deep)).append("<&r>");
|
||||||
} else if (target - eval > 1048) {
|
} else if (target - eval > 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
verbose("Large than (" + Main.expCount + ")");
|
Verbose.send("LOOP","Large than (" + Countroll.expCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,2,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.power(ri,2,deep)).append("<&r>");
|
||||||
} else if (target - eval > 128) {
|
} else if (target - eval > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
verbose("Big than (" + Main.factorCount + ")");
|
Verbose.send("LOOP","Big than (" + Countroll.factorCount + ")");
|
||||||
expression.append("<&b>*<&r><&a>").append(Increasers.multiply(ri,9,deep)).append("<&r>");
|
expression.append("<&b>*<&r><&a>").append(Increasers.multiply(ri,9,deep)).append("<&r>");
|
||||||
}
|
}
|
||||||
Main.addCount++;
|
Countroll.addCount++;
|
||||||
expression.append("<&b>+<&r><&e>").append(toAdd).append("<&r>");
|
expression.append("<&b>+<&r><&e>").append(toAdd).append("<&r>");
|
||||||
verbose("Less than (" + Main.addCount + ")");
|
Verbose.send("LOOP","Less than (" + Countroll.addCount + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eval > target) {
|
if (eval > target) {
|
||||||
Main.subCount++;
|
Countroll.subCount++;
|
||||||
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
||||||
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
|
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
|
||||||
verbose("Greater than (" + Main.subCount + ")");
|
Verbose.send("LOOP","Greater than (" + Countroll.subCount + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("Broke out of loop. Value: " + eval(expression.toString()));
|
Verbose.send("PROC","Broke out of loop. Value: " + eval(expression.toString()));
|
||||||
verbose("Expression: " + expression);
|
Verbose.send("EVAL","Expression: " + expression);
|
||||||
verbose("Expression (Cleaned): " + removeColors(expression.toString()));
|
Verbose.send("EVAL","Expression (Cleaned): " + removeColors(expression.toString()));
|
||||||
return expression.toString();
|
return expression.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +150,10 @@ public class Obf {
|
|||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
int initializer = random.nextInt(9)+1;
|
int initializer = random.nextInt(9)+1;
|
||||||
verbose("Initializing Expression: " + initializer);
|
|
||||||
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
||||||
|
|
||||||
while (eval(expression.toString()) != target) {
|
while (eval(expression.toString()) != target) {
|
||||||
Main.total++;
|
Countroll.total++;
|
||||||
int eval = (int) eval(expression.toString());
|
int eval = (int) eval(expression.toString());
|
||||||
int ri = random.nextInt(9)+1;
|
int ri = random.nextInt(9)+1;
|
||||||
|
|
||||||
@@ -114,30 +162,30 @@ public class Obf {
|
|||||||
|
|
||||||
if (eval < target) {
|
if (eval < target) {
|
||||||
if (target - eval > 4096) {
|
if (target - eval > 4096) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.power(ri,4,deep));
|
expression.append("<&b>*<&r>").append(Increasers.power(ri,4,deep));
|
||||||
} else if (target - eval > 1048) {
|
} else if (target - eval > 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.power(ri,2,deep));
|
expression.append("<&b>*<&r>").append(Increasers.power(ri,2,deep));
|
||||||
} else if (target - eval > 128) {
|
} else if (target - eval > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
expression.append("<&b>*<&r>").append(Increasers.multiply(ri,2,deep));
|
expression.append("<&b>*<&r>").append(Increasers.multiply(ri,2,deep));
|
||||||
}
|
}
|
||||||
Main.addCount++;
|
Countroll.addCount++;
|
||||||
expression.append("<&b>+<&r>").append(toAdd);
|
expression.append("<&b>+<&r>").append(toAdd);
|
||||||
}
|
}
|
||||||
if (eval > target) {
|
if (eval > target) {
|
||||||
if (eval - target > 4096) {
|
if (eval - target > 4096) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.power(ri,5,deep));
|
expression.append("<&b>-<&r>").append(Increasers.power(ri,5,deep));
|
||||||
} else if (eval - target> 1048) {
|
} else if (eval - target> 1048) {
|
||||||
Main.expCount++;
|
Countroll.expCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.power(ri,3,deep));
|
expression.append("<&b>-<&r>").append(Increasers.power(ri,3,deep));
|
||||||
} else if (eval - target > 128) {
|
} else if (eval - target > 128) {
|
||||||
Main.factorCount++;
|
Countroll.factorCount++;
|
||||||
expression.append("<&b>-<&r>").append(Increasers.multiply(ri,2,deep));
|
expression.append("<&b>-<&r>").append(Increasers.multiply(ri,2,deep));
|
||||||
}
|
}
|
||||||
Main.subCount++;
|
Countroll.subCount++;
|
||||||
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
||||||
expression.append("<&b>-<&r>").append(toAdd);
|
expression.append("<&b>-<&r>").append(toAdd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,136 +0,0 @@
|
|||||||
package me.trouper;
|
|
||||||
|
|
||||||
import me.trouper.Functions.Complexers;
|
|
||||||
import me.trouper.Functions.Obf;
|
|
||||||
import me.trouper.Utils.Timer;
|
|
||||||
import me.trouper.Utils.Utils;
|
|
||||||
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
import static me.trouper.Functions.Eval.eval;
|
|
||||||
import static me.trouper.Functions.Eval.evalM;
|
|
||||||
import static me.trouper.Utils.Utils.removeColors;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
public static boolean verbose;
|
|
||||||
public static boolean deep;
|
|
||||||
public static boolean color;
|
|
||||||
public static boolean printHelp;
|
|
||||||
|
|
||||||
/* Statistics */
|
|
||||||
public static int expCount = 0;
|
|
||||||
public static int factorCount = 0;
|
|
||||||
public static int addCount = 0;
|
|
||||||
public static int subCount = 0;
|
|
||||||
public static int divideCount = 0;
|
|
||||||
public static int powerCount = 0;
|
|
||||||
public static int rDivisorCount = 0;
|
|
||||||
public static int rDividendCount = 0;
|
|
||||||
public static int rootCount = 0;
|
|
||||||
public static int perfectCount = 0;
|
|
||||||
public static int total = 0;
|
|
||||||
public static void clearStats() {
|
|
||||||
expCount = 0;
|
|
||||||
factorCount = 0;
|
|
||||||
addCount = 0;
|
|
||||||
subCount = 0;
|
|
||||||
divideCount = 0;
|
|
||||||
powerCount = 0;
|
|
||||||
rDivisorCount = 0;
|
|
||||||
rDividendCount = 0;
|
|
||||||
rootCount = 0;
|
|
||||||
perfectCount = 0;
|
|
||||||
total = 0;
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
boolean doCopy = false;
|
|
||||||
String mode = "N";
|
|
||||||
|
|
||||||
for (String arg : args) {
|
|
||||||
switch (arg) {
|
|
||||||
case "--copy", "-c" -> doCopy = true;
|
|
||||||
case "--verbose", "-v" -> verbose = true;
|
|
||||||
case "--deep", "-d" -> deep = true;
|
|
||||||
case "--color", "-rgb" -> color = true;
|
|
||||||
case "--help", "--h", "-h" -> printHelp = true;
|
|
||||||
case "--mode=numselli", "-m=n" -> mode = "N";
|
|
||||||
case "--mode=duckgroup", "-m=d" -> mode = "D";
|
|
||||||
case "--mode=TEST", "-m=t" -> mode = "TEST";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Complexers.useRoot = !mode.equals("D");
|
|
||||||
Complexers.usePower = true;
|
|
||||||
Complexers.useDivide = true;
|
|
||||||
Complexers.useRDivisor = true;
|
|
||||||
Complexers.useRDividend = true;
|
|
||||||
|
|
||||||
|
|
||||||
if (mode.equals("TEST")) {
|
|
||||||
while (true) {
|
|
||||||
System.out.print("Enter an expression (or 'exit' to exit): ");
|
|
||||||
String userInput = scanner.next();
|
|
||||||
|
|
||||||
if (userInput.equals("exit")) {
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
double result = evalM(userInput);
|
|
||||||
System.out.println("Result: " + result);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printHelp) Utils.printHelp();
|
|
||||||
if (color) Utils.printColorKey();
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
System.out.print("Enter Target Integer: ");
|
|
||||||
if (scanner.hasNextInt()) {
|
|
||||||
int target = scanner.nextInt();
|
|
||||||
Timer obfTimer = Timer.start();
|
|
||||||
String expression = null;
|
|
||||||
switch (mode) {
|
|
||||||
case "N" -> expression = Obf.obfIntN(target, deep);
|
|
||||||
case "D" -> expression = Obf.obfIntD(target, deep);
|
|
||||||
}
|
|
||||||
long obfTime = obfTimer.end().timePassed();
|
|
||||||
double output = eval(removeColors(expression));
|
|
||||||
|
|
||||||
System.out.println("\nStatistics" +
|
|
||||||
"\nExponents: " + expCount +
|
|
||||||
"\nFactors: " + factorCount +
|
|
||||||
"\nAdditions: " + addCount +
|
|
||||||
"\nSubtractions: " + subCount +
|
|
||||||
"\nDivisors: " + divideCount +
|
|
||||||
"\nPowers: " + powerCount +
|
|
||||||
"\nmRootDividends: " + rDividendCount +
|
|
||||||
"\nmRootDivisors: " + rDivisorCount +
|
|
||||||
"\nRoots Taken: " + rootCount +
|
|
||||||
"\nPerfect Squares Found: " + perfectCount +
|
|
||||||
"\nTotal steps taken: " + total);
|
|
||||||
System.out.println("\nElapsed Time: " + obfTime + "ms");
|
|
||||||
System.out.println("\nTarget Integer: " + target);
|
|
||||||
|
|
||||||
if (output == target) {
|
|
||||||
System.out.println(Utils.activateColors("<&2h><&f>Expression Correct<&r>\n\n" + ((color) ? expression : removeColors(expression))));
|
|
||||||
if (doCopy) Utils.copyToClip(removeColors(expression));
|
|
||||||
clearStats();
|
|
||||||
} else {
|
|
||||||
System.out.println(Utils.activateColors("<&ch><&0>!!!! INCORRECT !!!!<&r>\n\n" + ((color) ? expression : removeColors(expression))));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("Exiting the program.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package me.trouper.Utils;
|
package me.trouper.Utils;
|
||||||
|
|
||||||
import me.trouper.Data.MC2Ansi;
|
import me.trouper.Data.MC2Ansi;
|
||||||
import me.trouper.Main;
|
import me.trouper.Countroll;
|
||||||
|
import me.trouper.Functions.Eval;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
@@ -9,14 +10,26 @@ import java.awt.datatransfer.StringSelection;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
public static int calcExp(int difference) {
|
||||||
|
int result = 1;
|
||||||
|
|
||||||
|
if (difference >= 4096) result = 2;
|
||||||
|
if (difference >= 8192) result = 3;
|
||||||
|
if (difference >= 16384) result = 4;
|
||||||
|
if (difference >= 32768) result = 5;
|
||||||
|
if (difference >= 65536) result = 6;
|
||||||
|
if (difference >= 131072) result = 7;
|
||||||
|
if (difference >= 262144) result = 8;
|
||||||
|
if (difference >= 524288) result = 9;
|
||||||
|
if (difference >= 1048576) result = 10;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public static void copyToClip(String text) {
|
public static void copyToClip(String text) {
|
||||||
StringSelection parsed = new StringSelection(text);
|
StringSelection parsed = new StringSelection(text);
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
clipboard.setContents(parsed,null);
|
clipboard.setContents(parsed,null);
|
||||||
}
|
}
|
||||||
public static void verbose(String text) {
|
|
||||||
if (Main.verbose) System.out.println(activateColors(text));
|
|
||||||
}
|
|
||||||
public static String removeColors(String input) {
|
public static String removeColors(String input) {
|
||||||
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
|
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
|
||||||
}
|
}
|
||||||
@@ -70,12 +83,20 @@ public class Utils {
|
|||||||
* @return The divisor
|
* @return The divisor
|
||||||
*/
|
*/
|
||||||
public static int moduRootDivisor(int dividend, int modulus) {
|
public static int moduRootDivisor(int dividend, int modulus) {
|
||||||
|
|
||||||
int divisor = dividend - modulus;
|
int divisor = dividend - modulus;
|
||||||
verbose("<&1h><&e>Finding mrDivisor:<&r> " +
|
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
|
||||||
"\nDividend (Given): " + dividend +
|
"\nDividend (Given): " + dividend +
|
||||||
"\nDivisor (Unknown): " + divisor +
|
"\nDivisor (Unknown): " + divisor +
|
||||||
"\nModulus (Given): " + modulus);
|
"\nModulus (Given): " + modulus +
|
||||||
|
"\nCheck: " + dividend + "%" + divisor + "=" + Eval.eval(dividend + "%" + divisor));
|
||||||
return divisor;
|
return divisor;
|
||||||
|
/*
|
||||||
|
int divisor = 1;
|
||||||
|
while (divisor * dividend % modulus != 0 || divisor != 1) {
|
||||||
|
divisor++;
|
||||||
|
}
|
||||||
|
return divisor;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +108,7 @@ public class Utils {
|
|||||||
*/
|
*/
|
||||||
public static int moduRootDividend(int divisor, int modulus) {
|
public static int moduRootDividend(int divisor, int modulus) {
|
||||||
int dividend = modulus + divisor;
|
int dividend = modulus + divisor;
|
||||||
verbose("<&1h><&e>Finding mrDivisor:<&r> " +
|
Verbose.send("UTIL","<&1h><&e>Finding mrDivisor:<&r> " +
|
||||||
"\nDividend (Unknown): " + dividend +
|
"\nDividend (Unknown): " + dividend +
|
||||||
"\nDivisor (Given): " + divisor +
|
"\nDivisor (Given): " + divisor +
|
||||||
"\nModulus (Given): " + modulus);
|
"\nModulus (Given): " + modulus);
|
||||||
|
|||||||
@@ -1,7 +1,32 @@
|
|||||||
package me.trouper.Utils;
|
package me.trouper.Utils;
|
||||||
|
|
||||||
public class Verbose {
|
import me.trouper.Countroll;
|
||||||
public static void send(String message, String klass, String type) {
|
|
||||||
|
|
||||||
|
public class Verbose {
|
||||||
|
public static boolean processes;
|
||||||
|
public static boolean all;
|
||||||
|
public static boolean loops;
|
||||||
|
public static boolean eval;
|
||||||
|
public static boolean complexers;
|
||||||
|
public static boolean increasers;
|
||||||
|
public static boolean utils;
|
||||||
|
public static boolean errors;
|
||||||
|
public static void send(String type, String message) {
|
||||||
|
message = Utils.activateColors(message);
|
||||||
|
if (all) {
|
||||||
|
System.out.println(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type.equals("INIT")) System.out.println(message);
|
||||||
|
if (type.equals("PROC") && processes) System.out.println(message);
|
||||||
|
if (type.equals("LOOP") && loops) System.out.println(message);
|
||||||
|
if (type.equals("UTIL") && utils) System.out.println(message);
|
||||||
|
if (type.equals("EVAL") && eval) System.out.println(message);
|
||||||
|
if (type.equals("COMP") && complexers) System.out.println(message);
|
||||||
|
if (type.equals("INCR") && increasers) System.out.println(message);
|
||||||
|
if (type.equals("ERR") && errors) {
|
||||||
|
System.out.println(message);
|
||||||
|
Countroll.errorCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: me.trouper.Main
|
Main-Class: me.trouper.Countroll
|
||||||
|
|||||||
Reference in New Issue
Block a user