mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-14 03:39:09 +00:00
Add new function count_bits_32() in inc_common.cl
This commit is contained in:
parent
13559cf902
commit
f8bd133373
@ -2992,6 +2992,24 @@ DECLSPEC int hc_execute_keyboard_layout_mapping (PRIVATE_AS u32 *w, const int pw
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int count_bits_32 (const u32 v0, const u32 v1)
|
||||
{
|
||||
u32 r = v0 ^ v1;
|
||||
|
||||
if (r == 0) return 0;
|
||||
|
||||
// from https://stackoverflow.com/questions/109023/count-the-number-of-set-bits-in-a-32-bit-integer
|
||||
|
||||
r = r - ((r >> 1) & 0x55555555); // add pairs of bits
|
||||
r = (r & 0x33333333) + ((r >> 2) & 0x33333333); // quads
|
||||
r = (r + (r >> 4)) & 0x0F0F0F0F; // groups of 8
|
||||
r *= 0x01010101; // horizontal sum of bytes
|
||||
|
||||
// return just that top byte (after truncating to 32-bit even when int is wider than uint32_t)
|
||||
|
||||
return r >> 24;
|
||||
}
|
||||
|
||||
/**
|
||||
* vector functions
|
||||
*/
|
||||
|
@ -315,6 +315,8 @@ DECLSPEC int is_valid_printable_8 (const u8 v);
|
||||
DECLSPEC int is_valid_printable_32 (const u32 v);
|
||||
DECLSPEC int hc_find_keyboard_layout_map (const u32 search, const int search_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt);
|
||||
DECLSPEC int hc_execute_keyboard_layout_mapping (PRIVATE_AS u32 *w, const int pw_len, LOCAL_AS keyboard_layout_mapping_t *s_keyboard_layout_mapping_buf, const int keyboard_layout_mapping_cnt);
|
||||
DECLSPEC int count_bits_32 (const u32 v0, const u32 v1);
|
||||
|
||||
DECLSPEC void make_utf16be (PRIVATE_AS const u32x *in, PRIVATE_AS u32x *out1, PRIVATE_AS u32x *out2);
|
||||
DECLSPEC void make_utf16beN (PRIVATE_AS const u32x *in, PRIVATE_AS u32x *out1, PRIVATE_AS u32x *out2);
|
||||
DECLSPEC void make_utf16beN_S (PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out1, PRIVATE_AS u32 *out2);
|
||||
|
Loading…
Reference in New Issue
Block a user