1 /* 2 * Developed by Claudio André <claudioandre.br at gmail.com> in 2012 3 * 4 * Copyright (c) 2012-2015 Claudio André <claudioandre.br at gmail.com> 5 * This program comes with ABSOLUTELY NO WARRANTY; express or implied. 6 * 7 * This is free software, and you are welcome to redistribute it 8 * under certain conditions; as expressed here 9 * http://www.gnu.org/licenses/gpl-2.0.html 10 */ 11 12 #ifdef HAVE_OPENCL 13 14 15 /* 16 * Public domain hash function by DJ Bernstein 17 * We are hashing almost the entire struct 18 */ common_salt_hash(void * salt,int salt_size,int salt_hash_size)19int common_salt_hash(void * salt, int salt_size, int salt_hash_size) 20 { 21 unsigned char *s = salt; 22 unsigned int hash = 5381; 23 unsigned int i; 24 25 for (i = 0; i < salt_size; i++) 26 hash = ((hash << 5) + hash) ^ s[i]; 27 28 return hash & (salt_hash_size - 1); 29 } 30 31 #endif /* HAVE_OPENCL */ 32