Ejemplo n.º 1
0
    DECLARE_SERIALIZATION_FRIENDS
    BPHASH_DECLARE_HASHING_FRIENDS

    virtual void hash(bphash::Hasher & h) const
    {
        h(key_, required_, help_);
        hash_(h);
    }
Ejemplo n.º 2
0
 bool validate(const std::string& pass, const std::string& hash)
 {
     assert(hash.size() == hash_len + SALT_LEN);
     size_t salt_pos = hash.size() - SALT_LEN;
     const std::string s = hash.substr(salt_pos);
     const std::string h2 = hash_(s, pass);
     return 0 == hash.compare(0, hash_len, h2);
 }
Ejemplo n.º 3
0
BasicTimer::BasicTimer(const char* myname)
: hash(hash_(myname))
, starttime(spring_gettime())

{
	nameIterator = hashToName.find(hash);
	if (nameIterator == hashToName.end()) {
		nameIterator = hashToName.insert(std::pair<int,std::string>(hash, myname)).first;
	}
}
Ejemplo n.º 4
0
ULng32 NAHashDictionary<K,V>::getHashCode(const K& key) const
{
//#if defined(NA_UNIX) && !defined(NA_LINUX)
  // use the key's hash method to get the hash value
//  unsigned long hashValue = key.hash() % hashSize_;
//#else
  ULng32 hashValue = hash_(key) % hashSize_;
//#endif
  assert(hashValue < hashSize_);
  return hashValue;
} //  NAHashDictionary<K,V>::getHashCode()
Ejemplo n.º 5
0
void Scene::detachNamed(const std::string& name, const std::string& fullname, ComponentBase* aspect) {
    aspect->setScene(nullptr);
    foundation::hash::remove(componentByName_, hash_(fullname));
    const foundation::Hash<ComponentBase*>::Entry* it = foundation::multi_hash::find_first(componentByObject_, hash_(name));
    while (it != nullptr) {
        if (it->value == aspect) {
            foundation::multi_hash::remove(componentByObject_, it);
            break;
        }
        it = foundation::multi_hash::find_next(componentByObject_, it);
    }
}
Ejemplo n.º 6
0
int
find_empty(tw_event ** hash_t, tw_event * event, int hash_size)
{
	unsigned int    i;
	int key;

	i = 0;
	key = hash_(event->event_id, hash_size);

	if(0 > key)
		tw_error(TW_LOC, "here!");

	while (hash_t[key])
	{
		key += 2 * (++i) - 1;
		if (key >= hash_size)
			key -= hash_size;
	}

	return key;
}
Ejemplo n.º 7
0
    bool cookie::parse_attr(std::string& name, std::string& value)
    {
      const std::size_t name_hash = hash_(name);
      if (name_hash == domain_hash)
      {
        domain_.resize(name.size());
        // lambda is required to build under gcc
        std::transform(name.cbegin(), name.cend(), domain_.begin(), [](int c){ return std::tolower(c); });
      }
      else if (name_hash == path_hash)
      {
        path_.swap(value);
      }
      else if (name_hash == expires_hash)
      {
        if (expires_ == time_point::max())
        {
          auto utime = time_from_string(value, "%a, %d-%b-%Y %T %Z");
          if (utime == -1)
            return false;

          expires_ = time_point::clock::from_time_t(utime);
        }
      }
      else if (name_hash == max_age_hash)
      {
        expires_ = time_point::clock::now() + std::chrono::seconds(from_dec_string(value));
      }
      else if (name_hash == secure_hash)
      {
        secure_ = true;
      }
      else if (name_hash == http_only_hash)
      {
        http_only_ = true;
      }
      return true;
    }
Ejemplo n.º 8
0
int
find_entry(tw_event ** hash_t, tw_event * event, int hash_size, int pe)
{
	unsigned int    i;
	int key;

	i = 0;
	key = hash_(event->event_id, hash_size);

	while (hash_t[key] == NULL || event->event_id != hash_t[key]->event_id)
	{
		key += 2 * (++i) - 1;
		if (key >= hash_size)
			key -= hash_size;

		if (key > hash_size)
		{
			tw_error(TW_LOC, "Cannot find event in hash table: PE %d, key %d, size %d\n", 
				pe, key, hash_size);
		}
	}

	return key;
}
Ejemplo n.º 9
0
 virtual OutTypePtr Call(std::string *arg=nullptr) {
   OKASSERT_FATAL(arg, "Programming error");
   size_t hashed = hash_(*arg);
   return MakeOwned(new std::string(Stringify(hashed)));
 }
Ejemplo n.º 10
0
 size_t operator()(const std::basic_string<CharT> &key) const {
     return hash_(ToLower(key));
 }
Ejemplo n.º 11
0
void Scene::attachNamed(const std::string& name, const std::string& fullname, ComponentBase* aspect) {
    aspect->setName(name);
    aspect->setScene(this);
    foundation::hash::set(componentByName_, hash_(fullname), aspect);
    foundation::multi_hash::insert(componentByObject_, hash_(name), aspect);
}
Ejemplo n.º 12
0
 std::string hash(const std::string& pass)
 {
     const std::string s = rnd(SALT_LEN);
     const std::string h = hash_(s, pass);
     return h+s;
 }
Ejemplo n.º 13
0
void taclex(const char *filename)
{
    int c;
    FILE *f;
    uint16_t state = TAC_CLEAR;
    char *buffer, *bptr, *fptr;
    
    f = fopen(filename, "r");
    if(!f){
        perror("File IO Error");
        exit(EXIT_FAILURE);
    }
    
    buffer = readfile(filename);
    tacsym = hash_(pjw_hashf, str_isequalf);
    
    for(fptr = bptr = buffer; *fptr != EOF; fptr++) {
        switch(*fptr) {
            case ' ':
            case '\t':
            case '\n':
            case '\r':
            case '\v':
                state |= TAC_WHITESPACE;
                break;
            case ':':
                state |= TAC_COL;
                break;
            case '_':
                state |= TAC_UNDER;
                break;
            case '.':
                state |= TAC_DOT;
                break;
            case '=':
                state |= TAC_EQ;
                break;
            case '<':
                state |= TAC_LESS;
                break;
            case '>':
                state |= TAC_MORE;
                break;
            case '-':
                state |= TAC_SUB;
                break;
            case '*':
                state |= TAC_MUL;
                break;
            case '/':
                state |= TAC_DIV;
                break;
            default:
                if(
                   (*fptr >= 'a' && *fptr <= 'z') ||
                   (*fptr >= 'A' && *fptr <= 'Z')
                   ) {
                        if(state | TAC_CLEAR)
                            state |= TAC_ALPHAFIRST;
                        state |= TAC_ALPHA;
                   }
                else if(*fptr >= '1' && *fptr <= '9'){
                    state |= TAC_NUM;
                }
                else {
                    fprintf(stderr, "Lexical Error: Unknown Character: %c\n", *fptr);
                }
                break;
        }
    }
}