Class CryptographyUtils

java.lang.Object
me.lucko.luckperms.common.webeditor.socket.CryptographyUtils

public final class CryptographyUtils extends Object
Utilities for public/private key crypto used by the web editor socket connection.
  • Method Details

    • parsePublicKey

      public static PublicKey parsePublicKey(String base64String) throws IllegalArgumentException
      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

      public static KeyPair generateKeyPair()
      Generate a public/private key pair.
      Returns:
      the generated key pair
    • sign

      public static String sign(PrivateKey privateKey, String msg)
      Signs msg using the given PrivateKey.
      Parameters:
      privateKey - the private key to sign with
      msg - the message
      Returns:
      a base64 string containing the signature
    • verify

      public static boolean verify(PublicKey publicKey, String msg, String signatureBase64)
      Verify that the given base64 encoded signature matches the given message and PublicKey.
      Parameters:
      publicKey - the public key that the message was supposedly signed with
      msg - the message
      signatureBase64 - the provided signature
      Returns:
      true if the signature is ok