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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:30:12+00:00 2026-05-24T03:30:12+00:00

I have a file selector in my cocoa application, but when you hit the

  • 0

I have a file selector in my cocoa application, but when you hit the “Select” button I don’t believe it actually stores, or uses that file. I need to use that file later to encrypt it. The user selects a file, enters a password in an NSSecureTextfield. Though this is impossible if I have no file to work with, how can I ACTUALLY select/use a file? I need to encrypt (256 bit AES) with the contents of that file. Once I actually store it, how would I access the data to encrypt it. It wouldn’t necessarily be a text file, but maybe a sound file perhaps.

Thanks so much for your help

  • 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-24T03:30:13+00:00Added an answer on May 24, 2026 at 3:30 am

    If I understand you correctly, you’ll first have to use a class like NDAlias (https://github.com/nathanday/ndalias) to create a “dynamic” link to your file. This is a link that will be maintained even if the file is in the meantime renamed or moved (on the same volume). It’s very easy to use:

    //store the alias
    NDAlias *alias = [NDAlias aliasWithPath:pathToYourFile
                                   fromPath:NSHomeDirectory()];
    
    //do whatever you want
    
    //later, restore the path (possibly the path has changed)
    NSString *path = [alias path];
    

    Note: If you want to just read the contents from the file right away, without doing anything in the meantime, there is of course no need for NDAlias at all.

    To read data from the file, you just do:

    NSData *data = [NSData dataWithContentsOfFile:path];
    

    To do AES-256 encryption, the SSCrypto framework (http://septicus.com/products/opensource/) is your best friend. It’s also very easy to use:

    NSString *somePassword = @"somePassword"
    NSData *passwordData = [somePassword dataUsingEncoding:NSUTF8StringEncoding];
    
    SSCrypto *sscrypto = [[SSCrypto alloc] initWithSymmetricKey:passwordData];
    [sscrypto setClearTextWithData:data];
    
    NSData *encryptedData = [sscrypto encrypt:@"aes-256-cbc"];
    

    And to decrypt this data you do this:

    NSString *somePassword2 = @"theSamePassword"
    NSData *passwordData2 = [somePassword2 dataUsingEncoding:NSUTF8StringEncoding];
    
    SSCrypto *sscrypto2 = [[SSCrypto alloc] initWithSymmetricKey:passwordData2];
    [sscrypto2 setCipherText:encryptedData];
    NSData *decryptedData = [sscrypto2 decrypt:@"aes-256-cbc"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have main window with button open file. On clicking file selector dialog shows
I have a file selector (which works as needed) but I wanted to add
I have an xml file with a selector in it that defines the different
In my main CSS file, I have my a:link selector set to display links
In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have csv file that looks like this: artist,year,id,video_name,new_video_id,file_root_name,video_type ,,,,,, Clay Aiken,1,clay_aiken,Sorry Seems To
I have a file that looks something like this def foo bar {{ //
The setting is the following: I have a cocoa object in a nib file
In a Qt application, I have a bunch of automatically-created QActions (menu items) that
I have implemented a file selector with a combobox. I want to write the

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.