security/nss/lib/freebl/mpi/utils/dec2hex.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  *  dec2hex.c
     3  *
     4  *  Convert decimal integers into hexadecimal
     5  *
     6  * This Source Code Form is subject to the terms of the Mozilla Public
     7  * License, v. 2.0. If a copy of the MPL was not distributed with this
     8  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    10 #include <stdio.h>
    11 #include <stdlib.h>
    12 #include <string.h>
    14 #include "mpi.h"
    16 int main(int argc, char *argv[])
    17 {
    18   mp_int  a;
    19   char   *buf;
    20   int     len;
    22   if(argc < 2) {
    23     fprintf(stderr, "Usage: %s <a>\n", argv[0]);
    24     return 1;
    25   }
    27   mp_init(&a); mp_read_radix(&a, argv[1], 10);
    28   len = mp_radix_size(&a, 16);
    29   buf = malloc(len);
    30   mp_toradix(&a, buf, 16);
    32   printf("%s\n", buf);
    34   free(buf);
    35   mp_clear(&a);
    37   return 0;
    38 }

mercurial