2
* This file is a part of Java Bindings for Librhash
3
* Copyright (c) 2011, Sergey Basalaev <sbasalaev@gmail.com>
4
* Librhash is (c) 2011, Alexey S Kravchenko <rhash.admin@gmail.com>
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
13
* This library is distributed in the hope that it will be useful, but WITHOUT
14
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
* FOR A PARTICULAR PURPOSE. Use it at your own risk!
21
* Type of hashing algorithm.
22
* Supported algorithms are MD4, MD5, SHA1/SHA2, Tiger,
23
* DC++ TTH, BitTorrent BTIH, AICH, EDonkey 2000 hash, GOST R 34.11-94,
24
* RIPEMD-160, HAS-160, EDON-R 256/512, Whirlpool and Snefru-128/256.
26
public enum HashType {
27
/** CRC32 checksum. */
37
/** Tiger tree hash */
39
/** BitTorrent info hash. */
41
/** EDonkey 2000 hash. */
45
/** Whirlpool hash. */
47
/** RIPEMD-160 hash. */
49
/** GOST R 34.11-94. */
51
GOST_CRYPTOPRO(1 << 12),
54
/** Snefru-128 hash. */
56
/** Snefru-256 hash. */
71
/** hash_id for the native API */
75
* Construct HashType for specified native hash_id
76
* @param hashId hash identifier for native API
78
private HashType(int hashId) {
83
* Returns hash_id for the native API.
84
* @return hash identifier
91
* Returns lowest <code>HashType</code> for given id mask.
92
* Used by <code>RHash.getDigest()</code>.
93
* @param flags mask of hash identifiers
94
* @return <code>HashType</code> object or <code>null</code>
95
* if no <code>HashType</code> for given mask exists
97
static HashType forHashFlags(int flags) {
98
if (flags == 0) return null;
100
while ((flags % 2) == 0) {
104
for (HashType t : HashType.values()) {
105
if (t.hashId == (1 << lowest)) return t;
111
* Returns size of binary digest for this type.
112
* @return size of binary digest, in bytes
114
public int getDigestSize() {
115
//TODO: rhash_get_digest_size