最佳答案
I am storing a openssl private Key EVP_PKEY as nsdata. For this I am serializing into a byte stream using the code below
unsigned char *buf, *p;
int len;
len = i2d_PrivateKey(pkey, NULL);
buf = OPENSSL_malloc(len);
p = buf;
i2d_PrivateKey(pkey, &p);
where pkey is of type EVP_PKEY. Then I am storing the bytes from buffer 'p' as an NSData using the line given below
NSData *keydata = [NSData dataWithBytes:P length:len];
Now I am converting it to a NSString using the code given below but when i print it into console its giving some other characters.
NSString *content =[ NSString stringWithCString:[keydata bytes] encoding:NSUTF8StringEncoding];
Could someone help?
Basically I want to store the EVP_PKEY into a sqlite database
am I on the right track? Thanks.