Package org.jivesoftware.smackx.hashes
Class HashManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.hashes.HashManager
-
public final class HashManager extends Manager
Manager that can be used to determine support for hash functions. By default the Manager announces support for XEP-0300, as well as for the recommended set of hash algorithms. Those contain SHA256, SHA384, SHA512, SHA3-256, SHA3-384, SHA3-512, BLAKE2B256, BLAKE2B384 and BLAKE2B512. Those algorithms got recommended here: https://xmpp.org/extensions/xep-0300.html#recommendations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HashManager.ALGORITHM
static class
HashManager.NAMESPACE
-
Field Summary
Fields Modifier and Type Field Description static String
PREFIX_NS_ALGO
static List<HashManager.ALGORITHM>
RECOMMENDED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAlgorithmsToFeatures(List<HashManager.ALGORITHM> algorithms)
Announce support for the given list of algorithms.static String
asFeature(HashManager.ALGORITHM algorithm)
Return the feature name of the given algorithm.static HashElement
assembleHashElement(HashManager.ALGORITHM algorithm, byte[] hash)
static byte[]
blake2b160(byte[] data)
static byte[]
blake2b160(String data)
static String
blake2b160HexString(byte[] data)
static String
blake2b160HexString(String data)
static byte[]
blake2b256(byte[] data)
static byte[]
blake2b256(String data)
static String
blake2b256HexString(byte[] data)
static String
blake2b256HexString(String data)
static byte[]
blake2b384(byte[] data)
static byte[]
blake2b384(String data)
static String
blake2b384HexString(byte[] data)
static String
blake2b384HexString(String data)
static byte[]
blake2b512(byte[] data)
static byte[]
blake2b512(String data)
static String
blake2b512HexString(byte[] data)
static String
blake2b512HexString(String data)
static HashElement
calculateHashElement(HashManager.ALGORITHM algorithm, byte[] data)
static HashManager
getInstanceFor(XMPPConnection connection)
Get an instance of the HashManager for the given connection.static MessageDigest
getMessageDigest(HashManager.ALGORITHM algorithm)
static byte[]
hash(HashManager.ALGORITHM algorithm, byte[] data)
Calculate the hash sum of data using algorithm.static byte[]
hash(HashManager.ALGORITHM algorithm, String data)
static byte[]
md5(byte[] data)
static byte[]
md5(String data)
static String
md5HexString(byte[] data)
static String
md5HexString(String data)
static byte[]
sha_1(byte[] data)
static byte[]
sha_1(String data)
static String
sha_1HexString(byte[] data)
static String
sha_1HexString(String data)
static byte[]
sha_224(byte[] data)
static byte[]
sha_224(String data)
static String
sha_224HexString(byte[] data)
static String
sha_224HexString(String data)
static byte[]
sha_256(byte[] data)
static byte[]
sha_256(String data)
static String
sha_256HexString(byte[] data)
static String
sha_256HexString(String data)
static byte[]
sha_384(byte[] data)
static byte[]
sha_384(String data)
static String
sha_384HexString(byte[] data)
static String
sha_384HexString(String data)
static byte[]
sha_512(byte[] data)
static byte[]
sha_512(String data)
static String
sha_512HexString(byte[] data)
static String
sha_512HexString(String data)
static byte[]
sha3_224(byte[] data)
static byte[]
sha3_224(String data)
static String
sha3_224HexString(byte[] data)
static String
sha3_224HexString(String data)
static byte[]
sha3_256(byte[] data)
static byte[]
sha3_256(String data)
static String
sha3_256HexString(byte[] data)
static String
sha3_256HexString(String data)
static byte[]
sha3_384(byte[] data)
static byte[]
sha3_384(String data)
static String
sha3_384HexString(byte[] data)
static String
sha3_384HexString(String data)
static byte[]
sha3_512(byte[] data)
static byte[]
sha3_512(String data)
static String
sha3_512HexString(byte[] data)
static String
sha3_512HexString(String data)
-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
PREFIX_NS_ALGO
public static final String PREFIX_NS_ALGO
- See Also:
- Constant Field Values
-
RECOMMENDED
public static final List<HashManager.ALGORITHM> RECOMMENDED
-
-
Method Detail
-
calculateHashElement
public static HashElement calculateHashElement(HashManager.ALGORITHM algorithm, byte[] data)
-
assembleHashElement
public static HashElement assembleHashElement(HashManager.ALGORITHM algorithm, byte[] hash)
-
addAlgorithmsToFeatures
public void addAlgorithmsToFeatures(List<HashManager.ALGORITHM> algorithms)
Announce support for the given list of algorithms.- Parameters:
algorithms
- TODO javadoc me please
-
getInstanceFor
public static HashManager getInstanceFor(XMPPConnection connection)
Get an instance of the HashManager for the given connection.- Parameters:
connection
- TODO javadoc me please- Returns:
- the manager for the given connection.
-
asFeature
public static String asFeature(HashManager.ALGORITHM algorithm)
Return the feature name of the given algorithm.- Parameters:
algorithm
- eg. 'SHA_1'- Returns:
- feature name (eg. urn:xmpp:hash-function-text-names:sha-1')
-
hash
public static byte[] hash(HashManager.ALGORITHM algorithm, byte[] data)
Calculate the hash sum of data using algorithm.- Parameters:
algorithm
- the algorithm to use.data
- the data to calculate the hash for.- Returns:
- the hash value produced by the given algorithm for the given data.
-
hash
public static byte[] hash(HashManager.ALGORITHM algorithm, String data)
-
getMessageDigest
public static MessageDigest getMessageDigest(HashManager.ALGORITHM algorithm)
-
md5
public static byte[] md5(byte[] data)
-
md5HexString
public static String md5HexString(byte[] data)
-
md5HexString
public static String md5HexString(String data)
-
sha_1
public static byte[] sha_1(byte[] data)
-
sha_1HexString
public static String sha_1HexString(byte[] data)
-
sha_1HexString
public static String sha_1HexString(String data)
-
sha_224
public static byte[] sha_224(byte[] data)
-
sha_224HexString
public static String sha_224HexString(byte[] data)
-
sha_224HexString
public static String sha_224HexString(String data)
-
sha_256
public static byte[] sha_256(byte[] data)
-
sha_256HexString
public static String sha_256HexString(byte[] data)
-
sha_256HexString
public static String sha_256HexString(String data)
-
sha_384
public static byte[] sha_384(byte[] data)
-
sha_384HexString
public static String sha_384HexString(byte[] data)
-
sha_384HexString
public static String sha_384HexString(String data)
-
sha_512
public static byte[] sha_512(byte[] data)
-
sha_512HexString
public static String sha_512HexString(byte[] data)
-
sha_512HexString
public static String sha_512HexString(String data)
-
sha3_224
public static byte[] sha3_224(byte[] data)
-
sha3_224HexString
public static String sha3_224HexString(byte[] data)
-
sha3_224HexString
public static String sha3_224HexString(String data)
-
sha3_256
public static byte[] sha3_256(byte[] data)
-
sha3_256HexString
public static String sha3_256HexString(byte[] data)
-
sha3_256HexString
public static String sha3_256HexString(String data)
-
sha3_384
public static byte[] sha3_384(byte[] data)
-
sha3_384HexString
public static String sha3_384HexString(byte[] data)
-
sha3_384HexString
public static String sha3_384HexString(String data)
-
sha3_512
public static byte[] sha3_512(byte[] data)
-
sha3_512HexString
public static String sha3_512HexString(byte[] data)
-
sha3_512HexString
public static String sha3_512HexString(String data)
-
blake2b160
public static byte[] blake2b160(byte[] data)
-
blake2b160
public static byte[] blake2b160(String data)
-
blake2b160HexString
public static String blake2b160HexString(byte[] data)
-
blake2b160HexString
public static String blake2b160HexString(String data)
-
blake2b256
public static byte[] blake2b256(byte[] data)
-
blake2b256
public static byte[] blake2b256(String data)
-
blake2b256HexString
public static String blake2b256HexString(byte[] data)
-
blake2b256HexString
public static String blake2b256HexString(String data)
-
blake2b384
public static byte[] blake2b384(byte[] data)
-
blake2b384
public static byte[] blake2b384(String data)
-
blake2b384HexString
public static String blake2b384HexString(byte[] data)
-
blake2b384HexString
public static String blake2b384HexString(String data)
-
blake2b512
public static byte[] blake2b512(byte[] data)
-
blake2b512
public static byte[] blake2b512(String data)
-
blake2b512HexString
public static String blake2b512HexString(byte[] data)
-
blake2b512HexString
public static String blake2b512HexString(String data)
-
-