make CC:keep better
This commit is contained in:
parent
d5ee578f57
commit
76dd2b4cd0
1 changed files with 28 additions and 7 deletions
|
@ -128,6 +128,11 @@ public class ChatCrypt extends Feature {
|
|||
|
||||
GlobalUtil.LOGGER.info("decrypt: {}", message);
|
||||
byte[] original = recoverBytes(message);
|
||||
if(!useSBE && decryptNoKeep(original).equals("CC:keep") && allowCCKeep) {
|
||||
keepTrypt = true;
|
||||
trypt = null;
|
||||
HUD.notifyAndPrint("§c§lChat>§c Enabled and synchronized Trypt keep.");
|
||||
}
|
||||
message = decrypt(original);
|
||||
|
||||
if(!useSBE && keepTrypt && (!isOurs || !sentOriginal.equals(message))) {
|
||||
|
@ -144,12 +149,6 @@ public class ChatCrypt extends Feature {
|
|||
sentEncrypted = null;
|
||||
sentOriginal = null;
|
||||
|
||||
if(!useSBE && message.equals("CC:keep") && allowCCKeep) {
|
||||
keepTrypt = true;
|
||||
trypt = null;
|
||||
HUD.notifyAndPrint("§c§lChat>§c Enabled and synchronized Trypt keep.");
|
||||
}
|
||||
|
||||
try {
|
||||
FieldFinder.findUnmarked(SPacketChat.class, ITextComponent.class, 0).set(e.getPacket(), new TextComponentString("§dChatCrypt> §r" + username + ": " + message));
|
||||
} catch (IllegalAccessException ex) {
|
||||
|
@ -179,6 +178,9 @@ public class ChatCrypt extends Feature {
|
|||
return;
|
||||
|
||||
sentOriginal = s;
|
||||
if(s.equals("CC:keep") && allowCCKeep)
|
||||
s = encryptNoKeep(s);
|
||||
else
|
||||
s = encrypt(s);
|
||||
sentEncrypted = s;
|
||||
s += getTerminator();
|
||||
|
@ -217,6 +219,25 @@ public class ChatCrypt extends Feature {
|
|||
}
|
||||
}
|
||||
|
||||
public String encryptNoKeep(String value) {
|
||||
if (useSBE) {
|
||||
SBE sbe = new SBE(Hasher.sha512hex(password).getBytes(StandardCharsets.UTF_8), boxSize, seed);
|
||||
return armorBytes(sbe.transform(value.getBytes(StandardCharsets.UTF_8)));
|
||||
} else {
|
||||
return armorBytes(new Trypt(seed, Hasher.sha512hex(password).getBytes(StandardCharsets.UTF_8)).encryptChunk(value.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
}
|
||||
|
||||
public String decryptNoKeep(byte[] encrypted) {
|
||||
if(useSBE) {
|
||||
SBE sbe = new SBE(Hasher.sha512hex(password).getBytes(StandardCharsets.UTF_8), boxSize, seed);
|
||||
return new String(sbe.transform(encrypted), StandardCharsets.US_ASCII);
|
||||
}
|
||||
else {
|
||||
return new String(new Trypt(seed, Hasher.sha512hex(password).getBytes(StandardCharsets.UTF_8)).decryptChunk(encrypted), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
final char[] table = "!#$%&'()*+,-0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~¡¢£¥¦«²³¹»ÆÇÈÉÊÑÒÓÖÙÚÜßàáäåæçèéêñòóöùü×".toCharArray();
|
||||
final byte[] rtable = new byte[256];
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue