net.named_data.jndn.util
public class Common extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_NDN_PACKET_SIZE
The practical limit of the size of a network-layer packet.
|
Constructor and Description |
---|
Common() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
base64Decode(String encoding)
Decode the input as base64 using the appropriate base64Converter_ from
establishBase64Converter(), for ANDROID or Java 7+.
|
static String |
base64Encode(byte[] input)
Encode the input as base64 using the appropriate base64Converter_ from
establishBase64Converter(), for ANDROID or Java 7+.
|
static byte[] |
computeHmacWithSha256(byte[] key,
ByteBuffer data)
Compute the HMAC with SHA-256 of data, as defined in
http://tools.ietf.org/html/rfc2104#section-2 .
|
static byte[] |
digestSha256(ByteBuffer data)
Compute the sha-256 digest of data.
|
static double |
getNowMilliseconds()
Get the current time in milliseconds.
|
static Random |
getRandom()
Get the library-wide random number generator.
|
static void |
setRandom(Random randomNumberGenerator)
Set the library-wide random number generator; this method will only allow the generator to be set once.
|
static String |
toHex(byte[] buffer)
Return a hex string of the contents of buffer.
|
public static final int MAX_NDN_PACKET_SIZE
public static double getNowMilliseconds()
public static Random getRandom()
setRandom(Random)
or (by default) a SecureRandompublic static void setRandom(Random randomNumberGenerator)
randomNumberGenerator
- the random number generatorUnsupportedOperationException
- if a user attempts to set the generator a second timepublic static byte[] digestSha256(ByteBuffer data)
data
- The input byte buffer. This does not change the position.public static byte[] computeHmacWithSha256(byte[] key, ByteBuffer data)
key
- The key byte array.data
- The input byte buffer. This does not change the position.public static String toHex(byte[] buffer)
buffer
- The buffer.public static String base64Encode(byte[] input)
input
- The bytes to encode.UnsupportedOperationException
- If can't establish a base64 converter for
this platform.public static byte[] base64Decode(String encoding) throws SecurityException
encoding
- The base64 string.UnsupportedOperationException
- If can't establish a base64 converter for
this platform.SecurityException
Copyright © 2016. All rights reserved.