参考:http://www.bolenot.ru/library/cmd/blcmdl3_uuid_generate_random.htm


char *psz_buf = malloc( 64 );
    if ( !psz_buf )
        return NULL;
uuid_t uu;

uuid_generate_random( uu );
uuid_unparse_upper( uu, psz_buf );

描述

uuid_generate函数创建一个新的通用唯一标识符(UUID)。 从 / dev / urandom的 ,如果可用的随机性高品质的基础上,将产生的UUID。 如果不可用,,然后 uuid_generate将使用另一种算法,它使用当前时间,本地以太网的MAC地址(如果可用),并随机数据产生,使用伪随机数发生器。

uuid_generate_random功能强制使用的所有随机UUID格式,高质量的随机数发生器(例如,/ dev / urandom的 ),即使是不提供的,在这种情况下,伪随机发生器将被换掉。 需要注意的是一个伪随机数发生器的使用可能危及以这种方式产生的UUID的唯一性。

uuid_generate_time功能强制使用的替代算法,它使用当前的时间和本地以太网的MAC地址(如果可用)。 该算法使用的是默认的用于生成的UUID,但因为使用的以太网MAC地址,它可以泄漏约在何时何地产生的UUID的信息。 这可能会导致在某些应用中的隐私问题,因此,uuid_generate功能只使用该算法的随机性高品质的来源无法使用。

UUID是16字节(128位),从而使约3.4x10 ^ 38(根据卡尔·萨根的宇宙,有大约10 ^ 80宇宙elemntary的粒子)独特的价值观。 可以合理地被视为新的UUID,其中在本地系统上创建的所有独特的UUID,在过去和未来之间的其他系统上创建的UUID。 

SYNOPSIS
       #include <uuid/uuid.h>

       void
       uuid_unparse(uuid_t uu, uuid_string_t out);

       void
       uuid_unparse_lower(uuid_t uu, uuid_string_t out);

       void
       uuid_unparse_upper(uuid_t uu, uuid_string_t out);


DESCRIPTION
       
SYNOPSIS
       #include <uuid/uuid.h>

       void
       uuid_unparse(uuid_t uu, uuid_string_t out);

       void
       uuid_unparse_lower(uuid_t uu, uuid_string_t out);

       void
       uuid_unparse_upper(uuid_t uu, uuid_string_t out);


DESCRIPTION
       The  uuid_unparse  function  converts  the  supplied  UUID  uu  from the binary representation into a
       uuid_string_t     (37-byte     string     including     tailing      '\0')      of      the      form
       1b4e28ba-2fa1-11d2-883f-b9a761bde3fb and stores this value in the character string pointed to by out.
       The case of the hex digits returned by uuid_unparse may be upper or lower case, and is  dependent  on
       the system-dependent local default.

       If   the   case   of   the  hex  digits  is  important  then  the  functions  uuid_unparse_upper  and
       uuid_unparse_lower may be used.

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐