<commit_before>#include <t4c/string.h>
#include <t4c/util.h>
#include <openssl/hmac.h>
#include <openssl/sha.h>

string hmac_sha1(string key, string data){
  string result = new_string(),
         res    = new_string();
  res.length = SHA_DIGEST_LENGTH + 1;
  res.value  = MALLOC_TN(char, res.length);

  HMAC(EVP_sha1(), 
      (const unsigned char*)string_get_value(key), key.length,
      (const unsigned char*)string_get_value(data), data.length,
      (unsigned char*)res.value, (unsigned int*)&res.length);

  return res;
}

<commit_msg>change way to get c-style string in src/hmac_sha1.c<commit_after>#include <t4c/string.h>
#include <t4c/util.h>
#include <openssl/hmac.h>
#include <openssl/sha.h>

string hmac_sha1(string key, string data){
  string result = new_string(),
         res    = new_string();
  res.length = SHA_DIGEST_LENGTH + 1;
  res.value  = MALLOC_TN(char, res.length);

  HMAC(EVP_sha1(), 
      (const unsigned char*)key.value, key.length,
      (const unsigned char*)data.value, data.length,
      (unsigned char*)res.value, (unsigned int*)&res.length);

  return res;
}


{'fraction_non_alphanumeric': 0.14636363636363636, 'fraction_numerical': 0.01, 'mean_word_length': 3.8933333333333335, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4353469', 'n_tokens_mistral': 416, 'n_tokens_neox': 398, 'n_words': 85}