Skip to content

Base64 Serialization

Hempfest edited this page Dec 5, 2021 · 8 revisions

Encrypt entire objects into singular strings with HFEncoded Anything attempting encryption is expected to inherit java.io Serializable or ConfigurationSerializable from bukkit, its important to know that along with implementation a unique id must be provided as well.

To String

String serialized = new HFEncoded(yourObjectHere).serialize();

From String

Object o = new HFEncoded(yourStringHere).deserialized(); // throws exception.

int i = new HFEncoded(yourStringHere).deserialize(Integer.class); // exceptions handled internally.

Example

public class TestClass implements Serializable {

	private static final long serialVersionUID = -5932203874408973373L;
	private final Map<String, Object> map = new HashMap<>();
	private String string;
	private Number number;

	public String getString() {
		return string;
	}

	public Number getNumber() {
		return number;
	}

	public Map<String, Object> getMap() {
		return map;
	}
}
String string = getTestClassAsString();
TestClass clazz = new HFEncoded(string).deserialize(TestClass.class);