Removes some real encryption ciphers, as even when converted to hex, some characters failed to decrypt correctly
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -15,7 +15,7 @@ public enum EncryptionStyle {
|
||||
/**
|
||||
* A simple cipher using the key to substitute one character for another
|
||||
*/
|
||||
SUBSTITUTION("substitution", true),
|
||||
SUBSTITUTION("substitution", false),
|
||||
|
||||
/**
|
||||
* A military-grade encryption cypher
|
||||
@@ -25,7 +25,7 @@ public enum EncryptionStyle {
|
||||
/**
|
||||
* An unbreakable encryption method assuming the key is completely random and never used more than once, ever
|
||||
*/
|
||||
ONE_TIME_PAD("onetimepad", true),
|
||||
ONE_TIME_PAD("onetimepad", false),
|
||||
|
||||
/**
|
||||
* Just a way of using magic text to make text illegible
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package net.knarcraft.bookswithoutborders.encryption;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -27,12 +26,12 @@ public class OneTimePad implements Encryptor {
|
||||
|
||||
@Override
|
||||
public @Nullable String encryptText(@NotNull String input) {
|
||||
return oneTimePad(input, true);
|
||||
return oneTimePad(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String decryptText(@NotNull String input) {
|
||||
return oneTimePad(input, false);
|
||||
return oneTimePad(input);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,16 +40,11 @@ public class OneTimePad implements Encryptor {
|
||||
* <p>The one time pad encryption is very secure, and encryption works just like decryption, but is vulnerable if
|
||||
* the same key is used more than once.</p>
|
||||
*
|
||||
* @param input <p>The input to encrypt/decrypt</p>
|
||||
* @param encrypt <p>Whether to encrypt or decrypt the input</p>
|
||||
* @param input <p>The input to encrypt/decrypt</p>
|
||||
* @return <p>The encrypted/decrypted output</p>
|
||||
*/
|
||||
@NotNull
|
||||
public String oneTimePad(@NotNull String input, boolean encrypt) {
|
||||
if (!encrypt) {
|
||||
input = new String(EncryptionHelper.hexStringToByteArray(input), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public String oneTimePad(@NotNull String input) {
|
||||
String longKey;
|
||||
try {
|
||||
final MessageDigest digest = MessageDigest.getInstance("SHA3-256");
|
||||
@@ -64,12 +58,7 @@ public class OneTimePad implements Encryptor {
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
output.append((char) (input.charAt(i) ^ longKey.charAt(i % longKey.length())));
|
||||
}
|
||||
|
||||
if (encrypt) {
|
||||
return EncryptionHelper.bytesToHex(output.toString().getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
return output.toString();
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
package net.knarcraft.bookswithoutborders.encryption;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
@@ -51,10 +49,6 @@ public class SubstitutionCipher implements Encryptor {
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
if (!encrypt) {
|
||||
input = new String(EncryptionHelper.hexStringToByteArray(input), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// converts each number in the key to an integer and adds to an array
|
||||
int[] offsetArray = getOffsetArray(this.key);
|
||||
|
||||
@@ -75,11 +69,7 @@ public class SubstitutionCipher implements Encryptor {
|
||||
}
|
||||
}
|
||||
|
||||
if (encrypt) {
|
||||
return EncryptionHelper.bytesToHex(output.toString().getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
||||
return output.toString();
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -34,6 +34,8 @@ Options:
|
||||
# Whether to enable hitting a chiseled bookshelf while sneaking to see the shelf's contents.
|
||||
Enable_Book_Peeking: true
|
||||
# Whether to use true AES encryption when encrypting and decrypting books. While the hashed password used for
|
||||
# encryption is still stored in the book file, the real contents of the book are not. Admin decrypt can be used to
|
||||
# peek at books, if an admin gets a hold of one, but only the encrypted AES cypher text is stored in the book.
|
||||
# encryption is still stored in the book file, the readable contents of the book are not. Admin decrypt can be used to
|
||||
# peek at books, if an admin gets a hold of a book with the same title and author, but only the encrypted AES cypher text is stored in the book.
|
||||
# Note that real encryption might alter, corrupt or lose a book's contents, so don't use real encryption with books
|
||||
# that have no backup in in-game book form or saved book form.
|
||||
Use_Real_Encryption: false
|
Reference in New Issue
Block a user