libsodium ed25519密钥生成器打印

时间:2018-06-25 18:04:16

标签: c libsodium ed25519

我正在尝试使用libsoudium生成密钥并打印它们。您的密钥存储在哪里,如何找到它们?这就是我要在C语言中完成的工作。

unsigned char pk[crypto_sign_PUBLICKEYBYTES];
    unsigned char sk[crypto_sign_SECRETKEYBYTES];
    int crypto_sign_keypair(unsigned char *pk, unsigned char *sk);
    printf("%s", pk);

这将输出:H��H�。是什么意思?

这里是我要调用的函数的文档。 https://download.libsodium.org/doc/public-key_cryptography/public-key_signatures.html

2 个答案:

答案 0 :(得分:1)

https://download.libsodium.org/doc/public-key_cryptography/public-key_signatures.html

例如:

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);

答案 1 :(得分:0)

尽管键由一定数量的$statement = ""; foreach ($_GET['providers'] as $providers) { $statement .= "AND ".$providers."= '1' "; // note the ".=" to append } $sql = "select * from users where user_id ='1' ".$statement." "; // to debug: echo "Query :: $sql"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); if(isset($row['user_id'])){ echo "It worked"; } 组成,但不能保证这些字符是可见的ASCII字符。我想您可能想用类似这样的循环来打印它们;

char