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 java.lang.String
PREFIX_NS_ALGO
static java.util.List<HashManager.ALGORITHM>
RECOMMENDED
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAlgorithmsToFeatures(java.util.List<HashManager.ALGORITHM> algorithms)
Announce support for the given list of algorithms.static java.lang.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(java.lang.String data)
static java.lang.String
blake2b160HexString(byte[] data)
static java.lang.String
blake2b160HexString(java.lang.String data)
static byte[]
blake2b256(byte[] data)
static byte[]
blake2b256(java.lang.String data)
static java.lang.String
blake2b256HexString(byte[] data)
static java.lang.String
blake2b256HexString(java.lang.String data)
static byte[]
blake2b384(byte[] data)
static byte[]
blake2b384(java.lang.String data)
static java.lang.String
blake2b384HexString(byte[] data)
static java.lang.String
blake2b384HexString(java.lang.String data)
static byte[]
blake2b512(byte[] data)
static byte[]
blake2b512(java.lang.String data)
static java.lang.String
blake2b512HexString(byte[] data)
static java.lang.String
blake2b512HexString(java.lang.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 java.security.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, java.lang.String data)
static byte[]
md5(byte[] data)
static byte[]
md5(java.lang.String data)
static java.lang.String
md5HexString(byte[] data)
static java.lang.String
md5HexString(java.lang.String data)
static byte[]
sha_1(byte[] data)
static byte[]
sha_1(java.lang.String data)
static java.lang.String
sha_1HexString(byte[] data)
static java.lang.String
sha_1HexString(java.lang.String data)
static byte[]
sha_224(byte[] data)
static byte[]
sha_224(java.lang.String data)
static java.lang.String
sha_224HexString(byte[] data)
static java.lang.String
sha_224HexString(java.lang.String data)
static byte[]
sha_256(byte[] data)
static byte[]
sha_256(java.lang.String data)
static java.lang.String
sha_256HexString(byte[] data)
static java.lang.String
sha_256HexString(java.lang.String data)
static byte[]
sha_384(byte[] data)
static byte[]
sha_384(java.lang.String data)
static java.lang.String
sha_384HexString(byte[] data)
static java.lang.String
sha_384HexString(java.lang.String data)
static byte[]
sha_512(byte[] data)
static byte[]
sha_512(java.lang.String data)
static java.lang.String
sha_512HexString(byte[] data)
static java.lang.String
sha_512HexString(java.lang.String data)
static byte[]
sha3_224(byte[] data)
static byte[]
sha3_224(java.lang.String data)
static java.lang.String
sha3_224HexString(byte[] data)
static java.lang.String
sha3_224HexString(java.lang.String data)
static byte[]
sha3_256(byte[] data)
static byte[]
sha3_256(java.lang.String data)
static java.lang.String
sha3_256HexString(byte[] data)
static java.lang.String
sha3_256HexString(java.lang.String data)
static byte[]
sha3_384(byte[] data)
static byte[]
sha3_384(java.lang.String data)
static java.lang.String
sha3_384HexString(byte[] data)
static java.lang.String
sha3_384HexString(java.lang.String data)
static byte[]
sha3_512(byte[] data)
static byte[]
sha3_512(java.lang.String data)
static java.lang.String
sha3_512HexString(byte[] data)
static java.lang.String
sha3_512HexString(java.lang.String data)
-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
PREFIX_NS_ALGO
public static final java.lang.String PREFIX_NS_ALGO
- See Also:
- Constant Field Values
-
RECOMMENDED
public static final java.util.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(java.util.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 java.lang.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, java.lang.String data)
-
getMessageDigest
public static java.security.MessageDigest getMessageDigest(HashManager.ALGORITHM algorithm)
-
md5
public static byte[] md5(byte[] data)
-
md5
public static byte[] md5(java.lang.String data)
-
md5HexString
public static java.lang.String md5HexString(byte[] data)
-
md5HexString
public static java.lang.String md5HexString(java.lang.String data)
-
sha_1
public static byte[] sha_1(byte[] data)
-
sha_1
public static byte[] sha_1(java.lang.String data)
-
sha_1HexString
public static java.lang.String sha_1HexString(byte[] data)
-
sha_1HexString
public static java.lang.String sha_1HexString(java.lang.String data)
-
sha_224
public static byte[] sha_224(byte[] data)
-
sha_224
public static byte[] sha_224(java.lang.String data)
-
sha_224HexString
public static java.lang.String sha_224HexString(byte[] data)
-
sha_224HexString
public static java.lang.String sha_224HexString(java.lang.String data)
-
sha_256
public static byte[] sha_256(byte[] data)
-
sha_256
public static byte[] sha_256(java.lang.String data)
-
sha_256HexString
public static java.lang.String sha_256HexString(byte[] data)
-
sha_256HexString
public static java.lang.String sha_256HexString(java.lang.String data)
-
sha_384
public static byte[] sha_384(byte[] data)
-
sha_384
public static byte[] sha_384(java.lang.String data)
-
sha_384HexString
public static java.lang.String sha_384HexString(byte[] data)
-
sha_384HexString
public static java.lang.String sha_384HexString(java.lang.String data)
-
sha_512
public static byte[] sha_512(byte[] data)
-
sha_512
public static byte[] sha_512(java.lang.String data)
-
sha_512HexString
public static java.lang.String sha_512HexString(byte[] data)
-
sha_512HexString
public static java.lang.String sha_512HexString(java.lang.String data)
-
sha3_224
public static byte[] sha3_224(byte[] data)
-
sha3_224
public static byte[] sha3_224(java.lang.String data)
-
sha3_224HexString
public static java.lang.String sha3_224HexString(byte[] data)
-
sha3_224HexString
public static java.lang.String sha3_224HexString(java.lang.String data)
-
sha3_256
public static byte[] sha3_256(byte[] data)
-
sha3_256
public static byte[] sha3_256(java.lang.String data)
-
sha3_256HexString
public static java.lang.String sha3_256HexString(byte[] data)
-
sha3_256HexString
public static java.lang.String sha3_256HexString(java.lang.String data)
-
sha3_384
public static byte[] sha3_384(byte[] data)
-
sha3_384
public static byte[] sha3_384(java.lang.String data)
-
sha3_384HexString
public static java.lang.String sha3_384HexString(byte[] data)
-
sha3_384HexString
public static java.lang.String sha3_384HexString(java.lang.String data)
-
sha3_512
public static byte[] sha3_512(byte[] data)
-
sha3_512
public static byte[] sha3_512(java.lang.String data)
-
sha3_512HexString
public static java.lang.String sha3_512HexString(byte[] data)
-
sha3_512HexString
public static java.lang.String sha3_512HexString(java.lang.String data)
-
blake2b160
public static byte[] blake2b160(byte[] data)
-
blake2b160
public static byte[] blake2b160(java.lang.String data)
-
blake2b160HexString
public static java.lang.String blake2b160HexString(byte[] data)
-
blake2b160HexString
public static java.lang.String blake2b160HexString(java.lang.String data)
-
blake2b256
public static byte[] blake2b256(byte[] data)
-
blake2b256
public static byte[] blake2b256(java.lang.String data)
-
blake2b256HexString
public static java.lang.String blake2b256HexString(byte[] data)
-
blake2b256HexString
public static java.lang.String blake2b256HexString(java.lang.String data)
-
blake2b384
public static byte[] blake2b384(byte[] data)
-
blake2b384
public static byte[] blake2b384(java.lang.String data)
-
blake2b384HexString
public static java.lang.String blake2b384HexString(byte[] data)
-
blake2b384HexString
public static java.lang.String blake2b384HexString(java.lang.String data)
-
blake2b512
public static byte[] blake2b512(byte[] data)
-
blake2b512
public static byte[] blake2b512(java.lang.String data)
-
blake2b512HexString
public static java.lang.String blake2b512HexString(byte[] data)
-
blake2b512HexString
public static java.lang.String blake2b512HexString(java.lang.String data)
-
-