Class CryptographyUtils
java.lang.Object
me.lucko.luckperms.common.webeditor.socket.CryptographyUtils
Utilities for public/private key crypto used by the web editor socket connection.
-
Method Summary
Modifier and TypeMethodDescriptionstatic KeyPairGenerate a public/private key pair.static PublicKeyparsePublicKey(String base64String) Parse a public key from the given string.static Stringsign(PrivateKey privateKey, String msg) Signsmsgusing the givenPrivateKey.static booleanVerify that the given base64 encoded signature matches the given message andPublicKey.
-
Method Details
-
parsePublicKey
Parse a public key from the given string.- Parameters:
base64String- a base64 string encoding the public key- Returns:
- the parsed public key
- Throws:
IllegalArgumentException- if the input was invalid
-
generateKeyPair
Generate a public/private key pair.- Returns:
- the generated key pair
-
sign
Signsmsgusing the givenPrivateKey.- Parameters:
privateKey- the private key to sign withmsg- the message- Returns:
- a base64 string containing the signature
-
verify
Verify that the given base64 encoded signature matches the given message andPublicKey.- Parameters:
publicKey- the public key that the message was supposedly signed withmsg- the messagesignatureBase64- the provided signature- Returns:
- true if the signature is ok
-