Encryption LibNade如何生成密钥对

Encryption LibNade如何生成密钥对,encryption,libsodium,nacl-cryptography,Encryption,Libsodium,Nacl Cryptography,对于libnaudio和libnaudio,我通常只需使用randombytes\u buf生成32个随机字节,然后使用crypto\u scalarmult\u base导出公钥(如果需要) 使用crypto\u box\u密钥对生成密钥对(语法除外)有什么好处吗?或者这个函数基本上就是这么做的 这正是crypto\u box\u keypair()函数所做的 此功能的好处是清晰,并保证正确生成密钥。 例如: unsigned char pk[crypto_sign_PUBLICKEY

对于libnaudio和libnaudio,我通常只需使用
randombytes\u buf
生成32个随机字节,然后使用
crypto\u scalarmult\u base
导出公钥(如果需要)


使用
crypto\u box\u密钥对
生成密钥对(语法除外)有什么好处吗?或者这个函数基本上就是这么做的

这正是
crypto\u box\u keypair()函数所做的

此功能的好处是清晰,并保证正确生成密钥。

例如:

    unsigned char pk[crypto_sign_PUBLICKEYBYTES]; //Variable declarations
    unsigned char sk[crypto_sign_SECRETKEYBYTES]; Variable declarations
    crypto_sign_keypair(pk, sk);

    NSData *privateKeyData = [NSData dataWithBytes:sk length:crypto_box_SECRETKEYBYTES];
    NSData *publicKeyData = [NSData dataWithBytes:pk length:crypto_box_PUBLICKEYBYTES];

    NSLog(@"%@",privateKeyData);  // target publick key data and secret key data
    NSLog(@"%@",publicKeyData);  
    //Other 
    NSLog(@"%s\n\n=====\n\n\n%s",pk,sk); //(nullable const void *)bytes
    Byte *byte = (Byte *)[publicKeyData bytes];
    NSLog(@"%s",byte);
一旦crypto_box_keypair()函数返回公钥和私钥,它们将作为uint8数组返回->如何将它们转换为可用字符串(以json格式发送)Na钠。to_字符串似乎不起作用