Package com.nimbusds.jose.util
Class Base64
- java.lang.Object
-
- com.nimbusds.jose.util.Base64
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Base64URL
@Immutable public class Base64 extends java.lang.Object implements java.io.SerializableBase64-encoded object.- Version:
- 2019-10-04
- Author:
- Vladimir Dzhuvinov
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Base64(java.lang.String base64)Creates a new Base64-encoded object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]decode()Decodes this Base64 object to a byte array.java.math.BigIntegerdecodeToBigInteger()Decodes this Base64 object to an unsigned big integer.java.lang.StringdecodeToString()Decodes this Base64 object to a string.static Base64encode(byte[] bytes)Base64-encodes the specified byte array.static Base64encode(java.lang.String text)Base64-encodes the specified string.static Base64encode(java.math.BigInteger bigInt)Base64-encodes the specified big integer, without the sign bit.booleanequals(java.lang.Object object)OverridesObject.equals().static Base64from(java.lang.String base64)Creates a new Base64-encoded object from the specified string.inthashCode()OverridesObject.hashCode().java.lang.StringtoJSONString()Returns a JSON string representation of this object.java.lang.StringtoString()Returns a Base64 string representation of this object.
-
-
-
Method Detail
-
decode
public byte[] decode()
Decodes this Base64 object to a byte array.- Returns:
- The resulting byte array.
-
decodeToBigInteger
public java.math.BigInteger decodeToBigInteger()
Decodes this Base64 object to an unsigned big integer.Same as
new BigInteger(1, base64.decode()).- Returns:
- The resulting big integer.
-
decodeToString
public java.lang.String decodeToString()
Decodes this Base64 object to a string.- Returns:
- The resulting string, in the UTF-8 character set.
-
toJSONString
public java.lang.String toJSONString()
Returns a JSON string representation of this object.- Returns:
- The JSON string representation of this object.
-
toString
public java.lang.String toString()
Returns a Base64 string representation of this object. The string will be chunked into 76 character blocks separated by CRLF.- Overrides:
toStringin classjava.lang.Object- Returns:
- The Base64 string representation, chunked into 76 character blocks separated by CRLF.
-
hashCode
public int hashCode()
OverridesObject.hashCode().- Overrides:
hashCodein classjava.lang.Object- Returns:
- The object hash code.
-
equals
public boolean equals(java.lang.Object object)
OverridesObject.equals().- Overrides:
equalsin classjava.lang.Object- Parameters:
object- The object to compare to.- Returns:
trueif the objects have the same value, otherwisefalse.
-
from
public static Base64 from(java.lang.String base64)
Creates a new Base64-encoded object from the specified string.- Parameters:
base64- The Base64-encoded object value,nullif not specified. The value is not validated for having characters from the Base64 alphabet.- Returns:
- The Base64-encoded object,
nullif not specified.
-
encode
public static Base64 encode(byte[] bytes)
Base64-encodes the specified byte array.- Parameters:
bytes- The byte array to encode. Must not benull.- Returns:
- The resulting Base64 object.
-
encode
public static Base64 encode(java.math.BigInteger bigInt)
Base64-encodes the specified big integer, without the sign bit.- Parameters:
bigInt- The big integer to encode. Must not benull.- Returns:
- The resulting Base64 object.
-
encode
public static Base64 encode(java.lang.String text)
Base64-encodes the specified string.- Parameters:
text- The string to encode. Must be in the UTF-8 character set and notnull.- Returns:
- The resulting Base64 object.
-
-