Class Base64Value

    • Method Detail

      • create

        public static Base64Value create​(String plainText)
        Create a base64 value from plain text. This method uses UTF-8 bytes of the string to create a base64 encoded string.
        Parameters:
        plainText - plain text to use
        Returns:
        a new value
      • create

        public static Base64Value create​(byte[] bytes)
        Create a base64 value from bytes. The bytes are encoded using base64.
        Parameters:
        bytes - bytes to use
        Returns:
        a new value
      • createFromEncoded

        public static Base64Value createFromEncoded​(String base64Text)
        Create from an already encoded base64 value.
        Parameters:
        base64Text - base64 to use (no encoding will be done)
        Returns:
        a new value
      • toBase64

        public String toBase64()
        Base64 encoded string.
        Returns:
        base64 value
      • toBytes

        public byte[] toBytes()
        Decoded value as bytes.
        Returns:
        bytes
      • toDecodedString

        public String toDecodedString()
        Returns decoded bytes as a string.

        WARNING - this method is potentially dangerous, as it uses the underlying bytes to create a new string without any validation whether it is in fact bytes fit for a readable string. Use only when the data is known to be a string.

        Returns:
        string value from the decoded bytes