Exemplo n.º 1
0
static uw_Basis_int __uwn_c_1099(uw_context ctx, uw_Basis_int __uwr_n_0)
{
    return(({
        uw_Basis_int disc0 = __uwr_n_0;
        uw_Basis_int result;
        {
            if (disc0 != 0LL) goto L4;
            result = 1LL;
            goto L3;
        }
L4:     {
            result = __uwn_d_1100(ctx, __uwr_n_0 - 1LL);
            goto L3;
        }
L5:
        uw_error(ctx, FATAL, "/mnt/sources/ur/tce.ur:6:10-10:0: pattern match failure");
L3:     result;
    }));
Exemplo n.º 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;
}