Package com.google.crypto.tink.util
Class Bytes
- java.lang.Object
-
- com.google.crypto.tink.util.Bytes
-
@Immutable public final class Bytes extends java.lang.ObjectImmutable Wrapper around a byte array.Wrap a bytearray so it prevents callers from modifying its contents. It does this by making a copy upon initialization, and also makes a copy if the underlying bytes are requested.
- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BytescopyFrom(byte[] data)static BytescopyFrom(byte[] data, int start, int len)Wrap an immutable byte array over a slice of a Bytesbooleanequals(java.lang.Object o)inthashCode()intsize()byte[]toByteArray()java.lang.StringtoString()
-
-
-
Method Detail
-
copyFrom
public static Bytes copyFrom(byte[] data)
- Parameters:
data- the byte array to be wrapped.- Returns:
- an immutable wrapper around the provided bytes.
-
copyFrom
public static Bytes copyFrom(byte[] data, int start, int len)
Wrap an immutable byte array over a slice of a Bytes- Parameters:
data- the byte array to be wrapped.start- the starting index of the slicelen- the length of the slice. If start + len is larger than the size ofdata, the remaining data will be returned.- Returns:
- an immutable wrapper around the bytes in the slice from
starttostart + len
-
toByteArray
public byte[] toByteArray()
- Returns:
- a copy of the bytes wrapped by this object.
-
size
public int size()
- Returns:
- the length of the bytes wrapped by this object.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-