mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-26 06:30:33 +00:00
* Handle entropy hash type from rahash2
This commit is contained in:
parent
4fad96ecbb
commit
d471bd6da2
@ -56,7 +56,7 @@ static int do_help(int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *algo = "md5,sha1"; /* default hashing algorithm */
|
const char *algo = "md5,sha1"; /* default hashing algorithm */
|
||||||
const ut8 *buf = NULL;
|
const ut8 *buf = NULL;
|
||||||
int c, buf_len = 0;
|
int c, buf_len = 0;
|
||||||
int bsize = 0;
|
int bsize = 0;
|
||||||
|
@ -46,6 +46,10 @@ R_API int r_hash_calculate(struct r_hash_t *ctx, int algobit, const ut8 *buf, ut
|
|||||||
ctx->digest[0] = r_hash_parity(buf, len);
|
ctx->digest[0] = r_hash_parity(buf, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (algobit & R_HASH_ENTROPY) {
|
||||||
|
ctx->digest[0] = (ut8)r_hash_entropy (buf, len);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (algobit & R_HASH_XOR) {
|
if (algobit & R_HASH_XOR) {
|
||||||
ctx->digest[0] = r_hash_xor(buf, len);
|
ctx->digest[0] = r_hash_xor(buf, len);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* radare - LGPL - Copyright 2007-2010 pancake<@nopcode.org> */
|
/* radare - LGPL - Copyright 2007-2011 pancake<@nopcode.org> */
|
||||||
|
|
||||||
#include "r_hash.h"
|
#include "r_hash.h"
|
||||||
|
|
||||||
@ -6,11 +6,9 @@
|
|||||||
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
|
R_API int r_hash_pcprint(const ut8 *buffer, ut64 len) {
|
||||||
const ut8 *end = buffer + len;
|
const ut8 *end = buffer + len;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for(n=0; buffer<end; buffer = buffer + 1)
|
for(n=0; buffer<end; buffer = buffer + 1)
|
||||||
if (IS_PRINTABLE(buffer[0]))
|
if (IS_PRINTABLE(buffer[0]))
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
return ((100*n)/len);
|
return ((100*n)/len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +49,8 @@ R_API ut8 r_hash_mod255(const ut8 *b, ut64 len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
R_API ut8 r_hash_deviation(const ut8 *b, ut64 len) {
|
R_API ut8 r_hash_deviation(const ut8 *b, ut64 len) {
|
||||||
int i, c = 0;
|
int i, c;
|
||||||
len--;
|
for (c = i = 0, --len; i < len; i++)
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
c += R_ABS (b[i+1] - b[i]);
|
c += R_ABS (b[i+1] - b[i]);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -67,6 +64,7 @@ R_API const char *r_hash_name(int bit) {
|
|||||||
if (bit & R_HASH_SHA384) return "sha384";
|
if (bit & R_HASH_SHA384) return "sha384";
|
||||||
if (bit & R_HASH_SHA512) return "sha512";
|
if (bit & R_HASH_SHA512) return "sha512";
|
||||||
if (bit & R_HASH_PARITY) return "parity";
|
if (bit & R_HASH_PARITY) return "parity";
|
||||||
|
if (bit & R_HASH_ENTROPY) return "entropy";
|
||||||
if (bit & R_HASH_XOR) return "xor";
|
if (bit & R_HASH_XOR) return "xor";
|
||||||
if (bit & R_HASH_XORPAIR) return "xorpair";
|
if (bit & R_HASH_XORPAIR) return "xorpair";
|
||||||
if (bit & R_HASH_MOD255) return "mod255";
|
if (bit & R_HASH_MOD255) return "mod255";
|
||||||
|
Loading…
Reference in New Issue
Block a user