public final class Util extends Object
| Modifier and Type | Field and Description |
|---|---|
static Charset |
UTF_8
Android 18-compatible alternative to
StandardCharsets.UTF_8. |
| Modifier and Type | Method and Description |
|---|---|
static Integer |
getAndroidApiLevel()
Returns the current Android API level as integer or null if we do not run on Android.
|
static boolean |
isAndroid()
Best-effort checks that this is Android.
|
static int |
randKeyId()
Returns a positive random int which can be used as a key ID in a keyset.
|
static Bytes |
toBytesFromPrintableAscii(String s)
Converts a string
s to a corresponding Bytes object. |
public static final Charset UTF_8
StandardCharsets.UTF_8.public static int randKeyId()
public static final Bytes toBytesFromPrintableAscii(String s)
s to a corresponding Bytes object.
The string must contain only printable ASCII characters; calling it in any other way is a considered a bug in Tink. Spaces are not allowed.
TinkBugException - if s contains a character which is not a printable ASCII character.public static boolean isAndroid()
Note: this is more tricky than it seems. For example, using reflection to see if android.os.Build.SDK_INT exists might fail because proguard might break the reflection part. Using build dispatching can also fail if there are issues in the build graph (see cl/510374081).