Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:08:22+00:00 2026-05-23T07:08:22+00:00

I am storing a openssl private Key EVP_PKEY as nsdata. For this I am

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:08:22+00:00Added an answer on May 23, 2026 at 7:08 am

    Objective-C

    You can use (see NSString Class Reference)

    - (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
    

    Example:

    NSString *myString = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];
    

    Remark: Please notice the NSData value must be valid for the encoding specified (UTF-8 in the example above), otherwise nil will be returned:

    Returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding).

    Prior Swift 3.0

    String(data: yourData, encoding: NSUTF8StringEncoding)
    

    Swift 3.0 Onwards

    String(data: yourData, encoding: .utf8)
    

    See String#init(data:encoding:) Reference

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code below to generate an OpenSSL RSA public and private
I'm using openssl BIO objects to convert a binary string into a base64 string.
I'm trying to sign a message using a private key that is encrypted, I
I am using the Linux command line, I have created a Private Key using
I have C# code as below: private static string password = Password; private static
Is storing secret keys (internal use passwords and such) on iPhone source code and
We're storing some Guid's in a MS SQL database. There's some legacy code that
i'm trying to write simple C openssl client and server. Here is client's code:
I have a legacy C++ module that offers encryption/decryption using the openssl library (DES
I've been trying for a while to generate an RSA keypair using PHP's openssl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.