package eu.mikroskeem.utils.text; import org.jetbrains.annotations.NotNull; import java.util.Base64; public class TextUtils { /** * Check if string contains whitespace * @param str String to check * @return Whether string contained whitespace or not */ public static boolean hasWhitespace(@NotNull String str){ return !str.matches("\\S+"); } /** * Encode string to Base64 (with padding) * @param str String to encode * @return Base64 encoded string */ @NotNull public static String b64enc(@NotNull String str){ return Base64.getEncoder().encodeToString(str.getBytes()); } /** * Decode Base64 to string * @param b64str Base64 encoded string * @return Decoded Base64 string */ @NotNull public static String b64dec(@NotNull String b64str){ return new String(Base64.getDecoder().decode(b64str)); } }