mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 00:37:57 +00:00
Wow such salt much security very wow.
This commit is contained in:
1 parent
1185317756
commit
e6464bbb6f
1 file changed
+39
-3
@@ -10,9 +10,14 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
@@ -98,13 +103,44 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
super.onWornTick(stack, player);
|
||||
if(stack.getItemDamage() != WING_TYPES && stack.getDisplayName().hashCode() == 0x7867EB0B) {
|
||||
public void onEquipped(ItemStack stack, EntityLivingBase player) {
|
||||
super.onEquipped(stack, player);
|
||||
if(stack.getItemDamage() != WING_TYPES && hash(stack.getDisplayName()).equals("FA1E5D9FD77D5C39776825E3D1AFAD365FB89B137567A78D538423B073A2EB93")) {
|
||||
stack.setItemDamage(WING_TYPES);
|
||||
stack.getTagCompound().removeTag("display");
|
||||
}
|
||||
}
|
||||
|
||||
String hash(String str) {
|
||||
if(str != null)
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
return new HexBinaryAdapter().marshal(md.digest(salt(str).getBytes()));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// Might as well be called sugar given it's not secure at all :D
|
||||
String salt(String str) {
|
||||
str = str += "wowsuchsaltmuchsecurityverywow";
|
||||
SecureRandom rand = new SecureRandom(str.getBytes());
|
||||
int l = str.length();
|
||||
int steps = rand.nextInt(l);
|
||||
char[] chrs = str.toCharArray();
|
||||
for(int i = 0; i < steps; i++) {
|
||||
int indA = rand.nextInt(l);
|
||||
int indB;
|
||||
do {
|
||||
indB = rand.nextInt(l);
|
||||
} while(indB == indA);
|
||||
char c = (char) ((int) chrs[indA] ^ (int) chrs[indB]);
|
||||
chrs[indA] = c;
|
||||
}
|
||||
|
||||
return String.copyValueOf(chrs);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void updatePlayerFlyStatus(LivingUpdateEvent event) {
|
||||
|
||||
Reference in new issue
Block a user