public enum CommonChecksumFunction extends Enum<CommonChecksumFunction> implements ChecksumFunction
CHECKSUM = SALT+MAXTIME+HASH where SALT
= 8 bytes of random positive Long JSON = JSON(Sorted Map<String,Object>
representing the object) MAXTIME = Long representing the maximum valid period
for this checksum, (optional) HASH = HASHFUNCTION(JSON+SALT+MAXTIME) (MAXTIME
is Long.MAX_VALUE if no TTL)| Modifier and Type | Method and Description |
|---|---|
String |
generateChecksum(String object)
Generate the checksum of an object
|
String |
generateChecksumWithTTL(String object,
long duration,
TimeUnit unit) |
boolean |
validateChecksum(String object,
String checksum) |
static CommonChecksumFunction |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static CommonChecksumFunction[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final CommonChecksumFunction MD5
public static final CommonChecksumFunction SHA1
public static final CommonChecksumFunction SHA256
public static final CommonChecksumFunction SHA512
public static CommonChecksumFunction[] values()
for (CommonChecksumFunction c : CommonChecksumFunction.values()) System.out.println(c);
public static CommonChecksumFunction valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String generateChecksum(String object)
ChecksumFunctiongenerateChecksum in interface ChecksumFunctionobject - a Stringpublic boolean validateChecksum(String object, String checksum)
validateChecksum in interface ChecksumFunctionobject - that we want to validate the checksum onchecksum - to validatepublic String generateChecksumWithTTL(String object, long duration, TimeUnit unit)
generateChecksumWithTTL in interface ChecksumFunctionCopyright © 2018–2019 Butor Inc.. All rights reserved.