public final class UtilChecksum extends Object
Example:
final Checksum checksum = Checksum.createSha256(); final int integer = 489464795; final String value = "keyToBeEncoded"; final String other = "anotherKey"; final String signature = checksum.getSha256(value); final String test = checksum.getSha256(integer); Assert.assertTrue(checksum.check(value, signature)); Assert.assertFalse(checksum.check(other, signature)); Assert.assertTrue(checksum.check(integer, test));
Modifier and Type | Method and Description |
---|---|
static boolean |
checkSha256(int value,
String signature)
Compare a checksum with its supposed original value.
|
static boolean |
checkSha256(String value,
String signature)
Compare a checksum with its supposed original value.
|
static String |
getSha256(byte[] bytes)
Get the SHA-256 signature of the input bytes.
|
static String |
getSha256(int i)
Get the SHA-256 signature of the input integer.
|
static String |
getSha256(String str)
Get the SHA-256 signature of the input string.
|
public static boolean checkSha256(String value, String signature)
value
- The original value.signature
- The checksum value.true
if corresponding (checksum of value is equal to its signature), false
else.public static boolean checkSha256(int value, String signature)
value
- The original value.signature
- The checksum value.true
if corresponding (checksum of value is equal to its signature), false
else.public static String getSha256(byte[] bytes)
bytes
- The input bytes.public static String getSha256(int i)
i
- The input integer.Copyright © 2016 Byron 3D Games Studio. All rights reserved.