示例#1
0
uw_Basis_string uw_EasyResponsiveTabs_js_c_text (uw_context ctx, uw_unit unit) {
  char* data = &blob[0];
  size_t size = sizeof(blob);
  char * c = uw_malloc(ctx, size+1);
  char * write = c;
  int i;
  for (i = 0; i < size; i++) {
    *write =  data[i];
    if (*write == '\0')
    *write = '\n';
    *write++;
  }
  *write=0;
  return c;
  }
示例#2
0
uw_Basis_string uw_Hash_sha512(uw_context ctx, uw_Basis_string str) {
  uw_Basis_string hash;
  MHASH td;
  int i;
  unsigned char *buf;

  td = mhash_init(MHASH_SHA512);

  if (td == MHASH_FAILED) 
    uw_error(ctx, FATAL, "uw_Hash_sha512: mhash_init(MHASH_SHA512) failed.");
  
  buf = uw_malloc(ctx, mhash_get_block_size(MHASH_SHA512));
  hash = uw_malloc(ctx, (mhash_get_block_size(MHASH_SHA512) * 2) + 1);

  mhash(td, str, uw_Basis_strlen(ctx, str));
  buf = mhash_end(td);

  for(i = 0; i < mhash_get_block_size(MHASH_SHA512); i++) {
    sprintf((hash + 2*i), "%02x", buf[i]);
  }
  hash[2 * i] = '\0';

  return hash;
}