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 6796513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:29:52+00:00 2026-05-26T18:29:52+00:00

I am trying to encrypt/decrypt one field of SQLite3 database stored in iPhone app.

  • 0

I am trying to encrypt/decrypt one field of SQLite3 database stored in iPhone app.

I am using this category mentioned in this question.

While encrypting, I am using following code:

NSString *key = @"pass123";
NSString *secret = webNote.note;

NSData *plain = [secret dataUsingEncoding:NSUTF8StringEncoding];
NSData *cipher = [plain AES256EncryptWithKey:key];

sqlite3_bind_text(statement, 1, [[cipher description] UTF8String], -1, SQLITE_TRANSIENT);    

It does save data into the field in 74657874 20746f20 656e6372 797074 format.

But while decrypting, I get blank field (tried everything I knew). I am using following code for decrypting:

char *noteDet = (char *)sqlite3_column_text(statement, 1);

NSString *key = @"pass123";
NSString *secret = [NSString stringWithUTF8String:noteDet];

NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding];

NSData *clean = [secretData AES256DecryptWithKey:key];
aNote.note = ([[NSString alloc] initWithData:clean encoding:NSUTF8StringEncoding])?[[NSString alloc] initWithData:clean encoding:NSUTF8StringEncoding]:@"";

I think, I am unable to convert types. Please guide!

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-26T18:29:53+00:00Added an answer on May 26, 2026 at 6:29 pm

    The description of NSData returns something like “” => if you were to read that again you would get different overall data ( and of a higher length ), also you are right that you are not converting the data types correctly.

    Try saving the NSData object directly, by saving the bytes themselves rather than the description of the NSData object.

    void *bytes = [dataObject bytes];
    size_t length = [dataObject length];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to encrypt and decrypt files with C++, using this code: #include <iostream>
I have been trying to encrypt/ decrypt a sqlite database in my iPhone project.
I'm trying to encrypt and decrypt data using RSA in C#. I have the
I am trying to encrypt/decrypt an XML file. I found this sample for encrypting
I'm trying to encrypt/decrypt files with PBE using AES. I'm using Bouncy Casle library(lightweight
I am trying to write encrypt/decrypt methods for AES 256 CBC encryption using PKCS5Padding
I'm trying to encrypt and decrypt a file stream over a socket using RijndaelManaged,
I'm trying to write a simple program to encrypt and decrypt files using the
I am trying to encrypt/decrypt a string using c#. I've found countless tutorials on
I'm trying to encrypt/decrypt a string using 128 bit AES encryption (ECB). What I

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.