libsodium ed25519 密钥生成器打印
libsodium ed25519 key generator printing
我正在尝试使用 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
虽然键由一定数量的 char
组成,但不能保证字符是可见的 ASCII 字符。我想您可能想用类似于此的循环打印它们;
for(i=0;i<crypto_sign_PUBLICKEYBYTES;i++)
printf("%2.2x",pk[i]);
puts("");
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);
我正在尝试使用 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
虽然键由一定数量的 char
组成,但不能保证字符是可见的 ASCII 字符。我想您可能想用类似于此的循环打印它们;
for(i=0;i<crypto_sign_PUBLICKEYBYTES;i++)
printf("%2.2x",pk[i]);
puts("");
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);