diff --git a/README.md b/README.md index 317e9bd..7a16539 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ # Voxelcraft - Java Sandbox game +Java Voxelcraft Game +## About + Developed with Jason Roberts + +Voxelcraft is a 3d java ray casting game. Survival and Creative modes are available so that the player can experience ultimate creative liberties, and a realistic experience. + +### Gameplay +![Image Not Found](https://raw.githubusercontent.com/Dunemask/Voxelcraft/master/Voxelcraft.jpeg) +Walk or fly around to create structures and explore your world! + +## Download and Run + +### Requirements + +This Project requires [Java](https://www.java.com/en/download/) + +### Download +
+
+ [Download](https://raw.githubusercontent.com/Dunemask/Voxelcraft/master/Voxelcraft) +
+
+ +## Planned Features +* Resource Pack Support +* Faster/Smoother Rendering +* Multiplayer Support +* Infinite Terrain Generation + +Source Code: [Voxelcraft](https://github.com/Dunemask/Voxelcraft) + + + + diff --git a/Voxelcraft.exe b/Voxelcraft.exe new file mode 100644 index 0000000..30b206f Binary files /dev/null and b/Voxelcraft.exe differ diff --git a/Voxelcraft.jpeg b/Voxelcraft.jpeg new file mode 100644 index 0000000..877a4cc Binary files /dev/null and b/Voxelcraft.jpeg differ diff --git a/source/VoxelCraft/.classpath b/source/VoxelCraft/.classpath new file mode 100644 index 0000000..e9ada77 --- /dev/null +++ b/source/VoxelCraft/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/VoxelCraft/.gitignore b/source/VoxelCraft/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/source/VoxelCraft/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/source/VoxelCraft/.project b/source/VoxelCraft/.project new file mode 100644 index 0000000..1610645 --- /dev/null +++ b/source/VoxelCraft/.project @@ -0,0 +1,17 @@ + + + VoxelCraft + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/source/VoxelCraft/.settings/org.eclipse.jdt.core.prefs b/source/VoxelCraft/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..25e312a --- /dev/null +++ b/source/VoxelCraft/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,13 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/source/VoxelCraft/jgoodies-forms-1.8.0-sources.jar b/source/VoxelCraft/jgoodies-forms-1.8.0-sources.jar new file mode 100644 index 0000000..ef31a30 Binary files /dev/null and b/source/VoxelCraft/jgoodies-forms-1.8.0-sources.jar differ diff --git a/source/VoxelCraft/jgoodies-forms-1.8.0.jar b/source/VoxelCraft/jgoodies-forms-1.8.0.jar new file mode 100644 index 0000000..7ea9ff0 Binary files /dev/null and b/source/VoxelCraft/jgoodies-forms-1.8.0.jar differ diff --git a/source/VoxelCraft/src/dunemasking/.gitignore b/source/VoxelCraft/src/dunemasking/.gitignore new file mode 100644 index 0000000..36582c6 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/.gitignore @@ -0,0 +1 @@ +/module-info.class diff --git a/source/VoxelCraft/src/dunemasking/dunemask/at/.gitignore b/source/VoxelCraft/src/dunemasking/dunemask/at/.gitignore new file mode 100644 index 0000000..bf8235f --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/at/.gitignore @@ -0,0 +1,2 @@ +/Plet.class +/RSACrypto.class diff --git a/source/VoxelCraft/src/dunemasking/dunemask/at/Plet.java b/source/VoxelCraft/src/dunemasking/dunemask/at/Plet.java new file mode 100644 index 0000000..33900c6 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/at/Plet.java @@ -0,0 +1,138 @@ +/** + * + */ +package dunemask.at; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.HashMap; + +import dunemask.util.RW; +import dunemask.util.StringUtil; + +/** + * @author Dunemask + * + */ +public class Plet { + + private HashMap map; + + public static Plet load(File f) { + Plet p = new Plet(); + try { + var lines = RW.readAll(f.toURI().toURL()); + String line; + String uuid; + String data; + final var splitChar = ":{"; + int ind = 0; + for(int i=0;i What is a plet?

+ *

A Plet is a data organizer that uses a UUID for every data value

+ * + */ + public Plet() { + this.setMap((new HashMap())); + } + /** Get attached Object from uuid + * @param uuid + * @return Attached Object + * + * */ + public Object getData(String uuid) { + return this.getMap().get(uuid); + } + /** Add Data + * @param uuid + * @param data + * + * */ + public void addData(String uuid,Object data) { + if(uuid.contains(":{")) { + throw new RuntimeException("UUID CANNOT CONTAIN :{"); + }else if(this.getMap().containsKey(uuid)) { + throw new RuntimeException("DATA ALREADY EXISTS UNDER THAT ENTRY!"); + }else { + this.getMap().put(uuid, data); + } + } + /** Edit Data + * @param uuid + * @param newData + * + * */ + public void editData(String uuid,Object newData) { + if(!this.getMap().containsKey(uuid)) { + throw new RuntimeException("UUID HAS NOT BEEN ESTABLISHED YET!"); + }else { + this.getMap().put(uuid, newData); + } + } + + /** Remove the entry + * @param uuid + * @return the value that was there if was there else null + * + * */ + public Object removeEntry(String uuid) { + return this.getMap().remove(uuid); + } + + /** Write the document + * @param out file + * + * */ + public void writeOut(File out) { + ArrayList lines = new ArrayList(getMap().size()); + var keys = new ArrayList(getMap().keySet()); + String format; + String key; + String data; + for(int i=0;i getMap() { + return map; + } + + + + /** + * @param map the map to set + */ + void setMap(HashMap map) { + this.map = map; + } + + +} diff --git a/source/VoxelCraft/src/dunemasking/dunemask/at/RSACrypto.java b/source/VoxelCraft/src/dunemasking/dunemask/at/RSACrypto.java new file mode 100644 index 0000000..ea52568 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/at/RSACrypto.java @@ -0,0 +1,271 @@ +/** + * + */ +package dunemask.at; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import javax.crypto.Cipher; + +/** + * @author Dunemask + * + */ +public class RSACrypto { + /** UTF-8 Encoding Style + *

Useage: String.getBytes(Crypto.UTF8)

+ * + * */ + public static final String UTF8 = "UTF-8"; + + + /** Encrypts the File with the Public Key + * @param f File + * @param pubkey Public Key + * + * */ + public static void encryptFile(File f,PublicKey pubkey) { + var in = RSACrypto.getBytes(f.toURI().toString()); + byte[] scrambled = null; + try { + scrambled = RSACrypto.encrypt(pubkey, in); + } catch (Exception e) { + e.printStackTrace(); + } + f.delete(); + RSACrypto.writeBytes(scrambled, f); + } + /**Decrypts a File with the PrivateKey + * @param f File + * @param prkey Private Key + * + * + * */ + public static void decryptFile(File f,PrivateKey prkey) { + var in = RSACrypto.getBytes(f.toURI().toString()); + byte[] unscrambled = null; + try { + unscrambled = RSACrypto.decrypt(prkey, in); + } catch (Exception e) { + e.printStackTrace(); + } + f.delete(); + RSACrypto.writeBytes(unscrambled, f); + } + + + + + + + + + + /** Write A Byte Array + * @param bytes + * @param out + * + * */ + public static void writeBytes(byte[] bytes,File out) { + try{ + FileOutputStream fos = new FileOutputStream(out); + fos.write(bytes); + fos.close(); + }catch(Exception e) { + e.printStackTrace(); + } + } + + /** Read Bytes from a path + * @param String path + * @return byte array + * + * */ + public static byte[] getBytes(String path) { + URL url = null; + InputStream is = null; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + url = new URL(path.replace(" ", "%20")); + is = url.openStream (); + byte[] byteChunk = new byte[4096]; // Or whatever size you want to read in at a time. + int n; + + while ( (n = is.read(byteChunk)) > 0 ) { + baos.write(byteChunk, 0, n); + } + } + catch (IOException e) { + System.err.printf ("Failed while reading bytes from %s: %s", url.toExternalForm(), e.getMessage()); + e.printStackTrace (); + // Perform any other exception handling that's appropriate. + } + finally { + if (is != null) { try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } } + } + return baos.toByteArray(); + } + + + + /** Read bytes from URI + * @param uri + * @return array of bytes from file + * + * + public static byte[] getBytes(URI uri) { + byte[] getBytes = {}; + try { + File file = new File(uri); + getBytes = new byte[(int) file.length()]; + InputStream is = new FileInputStream(file); + is.read(getBytes); + is.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return getBytes; + }*/ + + + + /**Get RSA Key Pair + * @param keysize + * @return RSA Key Pair + * + * */ + public static KeyPair getRSAKeyPair(int keysize) { + KeyPair pair = null; + KeyPairGenerator keyGen; + try { + keyGen = KeyPairGenerator.getInstance("RSA"); + keyGen.initialize(keysize); // key size specified here. + pair = keyGen.generateKeyPair(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return pair; + + } + /** Write Private Key + * @param priv Private Key + * @param out Out File + * + * */ + public static void writePrivKey(PrivateKey priv,File out) { + byte[] key = priv.getEncoded(); + try { + FileOutputStream keyfos = new FileOutputStream(out); + keyfos.write(key); + keyfos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + /** Write Public Key + * @param pub Public Key + * @param out Out File + * + * */ + public static void writePubKey(PublicKey pub,File out) { + byte[] key = pub.getEncoded(); + try { + FileOutputStream keyfos = new FileOutputStream(out); + keyfos.write(key); + keyfos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + + /**Get the Public Key From file! + * @param uri + * @return + * @return Public Key From File; + */ + public static PublicKey getPubKey(URI uri) { + PublicKey out = null; + try { + byte[] kb = Files.readAllBytes(Paths.get(uri)); + X509EncodedKeySpec spec = + new X509EncodedKeySpec(kb); + KeyFactory kf = KeyFactory.getInstance("RSA"); + out = kf.generatePublic(spec); + } catch (Exception e) { + e.printStackTrace(); + } + + return out; + + } + + + + + /** Get Private Key from file! + * @param uri + * @return Private Key From File + */ + public static PrivateKey getPrivKey(URI uri) { + PrivateKey out = null; + try { + byte[] kb = Files.readAllBytes(Paths.get(uri)); + PKCS8EncodedKeySpec spec = + new PKCS8EncodedKeySpec(kb); + KeyFactory kf = KeyFactory.getInstance("RSA"); + out = kf.generatePrivate(spec); + } catch (Exception e) { + e.printStackTrace(); + } + return out; + } + /** Encrypt bytes with public key + * @param pub + * @param decrypted + * @return encrypted byte array + * + * */ + public static byte[] encrypt(PublicKey pub, byte[] decrypted) throws Exception { + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.ENCRYPT_MODE, pub); + + return cipher.doFinal(decrypted); + } + /** Decrypt bytes with private key + * @param priv + * @param encrypted + * @return decrypted byte array + * + * */ + public static byte[] decrypt(PrivateKey priv, byte[] encrypted) throws Exception { + Cipher cipher = Cipher.getInstance("RSA"); + cipher.init(Cipher.DECRYPT_MODE, priv); + + return cipher.doFinal(encrypted); + } +} diff --git a/source/VoxelCraft/src/dunemasking/dunemask/crypto/.gitignore b/source/VoxelCraft/src/dunemasking/dunemask/crypto/.gitignore new file mode 100644 index 0000000..e4c7d5e --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/crypto/.gitignore @@ -0,0 +1,5 @@ +/CryptoUtil$Cipher.class +/CryptoUtil.class +/KeyPair.class +/PrivKey.class +/PubKey.class diff --git a/source/VoxelCraft/src/dunemasking/dunemask/crypto/CryptoUtil.java b/source/VoxelCraft/src/dunemasking/dunemask/crypto/CryptoUtil.java new file mode 100644 index 0000000..16ccbd6 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/crypto/CryptoUtil.java @@ -0,0 +1,192 @@ +/** + * + */ +package dunemask.crypto; + +import java.io.File; +import java.math.BigInteger; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; + +import dunemask.util.IOUtil; +import dunemask.util.RW; +import dunemask.util.StringUtil; + +/** + * @author Dunemask + * + */ +public class CryptoUtil { + + /** Encrypts a file using the Public Key + * @param key Public Key + * @param file File + * + * */ + public static void encryptFile(PubKey key,File file) { + var in = IOUtil.getBytes(IOUtil.FTU(file)); + byte[] encrypted = null; + try { + encrypted = CryptoUtil.encrypt(key, in); + }catch(java.lang.ArithmeticException e) { + throw new RuntimeException("Ensure data is less than 200MB!"); + } + + file.delete(); + IOUtil.writeBytes(encrypted, file); + } + /** Decrypts a file using the Private Key + * @param key Private Key + * @param file File + * + * */ + public static void decryptFile(PrivKey key,File file) { + var in = IOUtil.getBytes(IOUtil.FTU(file)); + var decrypted = CryptoUtil.decrypt(key, in); + file.delete(); + IOUtil.writeBytes(decrypted, file); + } + + + + + /** Write Public Key + * @param key Public Key + * @param file File + * + * */ + public static void writePubKey(PubKey key,File file) { + String code = key.getCode(); + String pform = "DMPUBKey:{"+code+"}"; + RW.writeAll(file, new ArrayList(Arrays.asList(new String[] {pform}))); + } + + /** Write Private Key + * @param key Private Key + * @param file File + * + * */ + public static void writePrivKey(PrivKey key,File file) { + String code = key.getCode(); + String ucode = CryptoUtil.Cipher.getCode(key.getUval()); + String pform = "DMPKey:{"+code+"}"; + String uform = "DMKey:{"+ucode+"}"; + RW.writeAll(file, new ArrayList(Arrays.asList(new String[] {pform,uform}))); + } + /** Read Private Key + * @parm url + * @return Private Key + * + * */ + public static PrivKey readPrivKey(URL url) { + var lines = RW.readAll(url); + var pcode = StringUtil.replaceLast(lines.get(0).replace("DMPKey:{", ""),"}",""); + var ucode = StringUtil.replaceLast(lines.get(1).replace("DMKey:{", ""),"}",""); + int pval = Cipher.getVal(pcode); + int uval = Cipher.getVal(ucode); + return new PrivKey(pval,uval); + } + + /** Read Public Key + * @parm url + * @return pubkey + * + * */ + public static PubKey readPubKey(URL url) { + var lines = RW.readAll(url); + var code = StringUtil.replaceLast(lines.get(0).replace("DMPUBKey:{", ""),"}",""); + int val = Cipher.getVal(code); + return new PubKey(val); + } + + + /** Encrypt data + * @param pub Public Key + * @param data Data + * @return encrypted form of data(Use private key to decrypt) + * + * + * + * */ + public static byte[] encrypt(PubKey pub,byte[] data) { + byte[] ret = null; + var init = new BigInteger(data); + var mult = BigInteger.valueOf(pub.getPval()); + var out = init.multiply(mult); + ret = out.toByteArray(); + return ret; + } + /** Decrypt Data + * @param pkey Private Key + * @param data + * @return Decrypted form of Data + * + * + * + * */ + public static byte[] decrypt(PrivKey pkey,byte[] data) { + byte[] ret = null; + var dat = new BigInteger(data); + var pubval = BigInteger.valueOf(pkey.getUval()/pkey.getPval()); + var out = dat.divide(pubval); + ret = out.toByteArray(); + return ret; + } + + static class Cipher{ + + + + static final int base = 33; + static int getVal(String code) { + int val = 0; + var cval = code.toCharArray(); + var spl = new ArrayList(cval.length); + for(int i=0;i(cval.length); + for(int i=0;iBigger is more difficult to decrypt

+ * + * */ + static KeyPair gen(int max) { + var pnum = calcPrime(max); + var sr = new SecureRandom(); + int priv = pnum.get(sr.nextInt(pnum.size())); + int pub = 0; + do{ + pub = pnum.get(sr.nextInt(pnum.size())); + }while(pub==priv); //Prevent them from being the same + KeyPair kp = new KeyPair(priv,pub); + return kp; + } + /** Test if the pair are indeed a pair ^^ + * @param pub Public Key + * @param priv Private key + * @return pair || no pair + * */ + public static boolean verifyPair(PubKey pub,PrivKey priv) { + int pubval = CryptoUtil.Cipher.getVal(pub.getCode()); + int prival = CryptoUtil.Cipher.getVal(priv.getCode()); + return ((pubval*prival)==priv.getUval()); + + } + + + + + + private static ArrayList calcPrime(int mx) { + boolean[] numberList = new boolean[mx+1]; + ArrayList nums = new ArrayList(mx); + for(int i=3;i<=Math.sqrt(mx);i+=2) { + + for(int j=i;i*j<=mx;j+=2) { + numberList[i*j] = true; + } + } + nums.add(2); + for(int i=3;i<=mx;i+=2) { + if(!numberList[i]){ + nums.add(i); + } + + + } + + + return nums; + + + } + + /** + * @return the Private Key + */ + public PrivKey getPriv() { + return priv; + } + + /** + * @return the Public Key + */ + public PubKey getPub() { + return pub; + } + + +} diff --git a/source/VoxelCraft/src/dunemasking/dunemask/crypto/PrivKey.java b/source/VoxelCraft/src/dunemasking/dunemask/crypto/PrivKey.java new file mode 100644 index 0000000..d2fe690 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/crypto/PrivKey.java @@ -0,0 +1,52 @@ +/** + * + */ +package dunemask.crypto; + +/** + * @author Dunemask + * + */ +public class PrivKey { + + private int uval; + private int pval; + private String val; + /**Private Key + * @param pval Private Value + * @param uval Unlock Value + * + */ + PrivKey(int pval,int uval) { + this.pval = pval; + this.uval = uval; + this.val = CryptoUtil.Cipher.getCode(pval); + } + /** + * @return the uval + */ + int getUval() { + return uval; + } + + + /** + * @return the pval + */ + int getPval() { + return pval; + } + + @Override + public String toString() { + return val; + } + /** + * @return the code Same as toString + * + * */ + public String getCode() { + return toString(); + } + +} diff --git a/source/VoxelCraft/src/dunemasking/dunemask/crypto/PubKey.java b/source/VoxelCraft/src/dunemasking/dunemask/crypto/PubKey.java new file mode 100644 index 0000000..6f7a5b7 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/crypto/PubKey.java @@ -0,0 +1,41 @@ +/** + * + */ +package dunemask.crypto; + +/** + * @author Dunemask + * + */ +public class PubKey { + + private int pval; + private String val; + /** + * + */ + PubKey(int pval) { + this.pval = pval; + this.val = CryptoUtil.Cipher.getCode(pval); + } + + + /** + * @return the pubval + */ + int getPval() { + return pval; + } + + @Override + public String toString() { + return val; + } + /** + * @return the code Same as toString + * + * */ + public String getCode() { + return toString(); + } +} diff --git a/source/VoxelCraft/src/dunemasking/dunemask/dm/.gitignore b/source/VoxelCraft/src/dunemasking/dunemask/dm/.gitignore new file mode 100644 index 0000000..d03b0ce --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/dm/.gitignore @@ -0,0 +1,8 @@ +/Capture$1.class +/Capture$2.class +/Capture$3.class +/Capture.class +/Dunemasking.class +/GitHub.class +/StreamGobbler.class +/package-info.class diff --git a/source/VoxelCraft/src/dunemasking/dunemask/dm/package-info.java b/source/VoxelCraft/src/dunemasking/dunemask/dm/package-info.java new file mode 100644 index 0000000..182a01a --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/dm/package-info.java @@ -0,0 +1,11 @@ +/**Tools for either working on, or setting up a Dunemasking Project + * + *

Changelog Class: {@link dunemask.dm.Changelog}

+ *

Setup Class: {@link dunemask.dm.Setup}

+ *

Src Class: {@link dunemask.dm.Src}

+ *

Version Class: {@link dunemask.dm.Version}

+ *

GitHub Station: {@link dunemask.dm.GitHub}}

+ * @author Elijah + */ +package dunemask.dm; + diff --git a/source/VoxelCraft/src/dunemasking/dunemask/objects/.gitignore b/source/VoxelCraft/src/dunemasking/dunemask/objects/.gitignore new file mode 100644 index 0000000..5038ec4 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/objects/.gitignore @@ -0,0 +1,4 @@ +/ArrayListState.class +/DMediaPlayer$1.class +/DMediaPlayer.class +/Expression.class diff --git a/source/VoxelCraft/src/dunemasking/dunemask/objects/Expression.java b/source/VoxelCraft/src/dunemasking/dunemask/objects/Expression.java new file mode 100644 index 0000000..332ddd9 --- /dev/null +++ b/source/VoxelCraft/src/dunemasking/dunemask/objects/Expression.java @@ -0,0 +1,153 @@ +/** + * + */ +package dunemask.objects; + +import java.io.Serializable; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + +/**Create an expression and call the Solve Function to solve it + * + * * @author Elijah + * + */ +public class Expression implements Serializable{ + + + + /** + * + */ + private static final long serialVersionUID = -8079254251686484945L; + /***Version*/ + final static double version = 4.5; + private String expression; + private String intExpression; + private int[] vari; + public static String operators = "*%/+-"; + private String[] varNames; + private int answer; + + /**Create an expression and call the Solve Function to solve it + * @param expression Mathematical Expression + * @param varNames Names of all Variables + * @param vari Ints that coreespond to the varNames; + */ + public Expression(String expression,String[]varNames,int[] vari) { + this.expression = expression; + if(varNames.length!=vari.length) { + throw new RuntimeException("TOO MANY VARIABLES OR NAMES!"); + } + + for(int i=0;i"+newChar); + } + return String.valueOf(stuff); + } + + /**Randomly creates keys and expressions + * (To get keys call expression.getVari() ) + * @param keyNumber number of keys in expression + * @return Returns randomly generated expression + * */ + + public static Expression RandomEncryptionKeyCode(int keyNumber) { + + //List of operators (/ not included because it gives decimals) + String operators = "*+^-%"; + //Array List of Integers {The keys} + ArrayList keys = new ArrayList<>(); + //Array List of names {Variable names for expressions} + ArrayList names = new ArrayList<>(); + for(int i=0;i=0;c--) { + text= decrypt(exp[c],text, keys[c]); + } + return text; + } + + /**Encrypt a String through layers of DM encryption + * @param text Text that will be encrypted + * @param layers Layers that the text will go through + * @param exp Expressions that the code has been through + * @param keys Key array that solves the expression + * @return decrypted Text + * + * */ + public static String layeredEncryption(String text,int layers, Expression[] exp,int[][] keys) { + layers++; + for(int c=0;cEncrypting for Strings: {@link dunemask.other.StringBasedEncryption}

+ * @author Elijah + * + */ +package dunemask.other; + +/* + * + * + + + + + + + + + +