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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:55:23+00:00 2026-05-29T09:55:23+00:00

I am working on an OSX application using Objective-C, and one of the things

  • 0

I am working on an OSX application using Objective-C, and one of the things I need to do is read text/xml files which were encrypted on a Windows machine using a simple bit-shift algorithm. The encryption code on the Windows side is fairly simple, in Delphi:

const
  EncryptKey : word = ????;
var
  InMS  : TMemoryStream;
  cnt   : Integer;
  c     : byte;
begin
  InMS    := TMemoryStream.Create;
  result  := TMemoryStream.Create;
  try
    InMS.LoadFromFile( FileName );
    InMS.Position := 0;
    for cnt := 0 to InMS.Size - 1 do
      begin
      InMS.Read( c, 1 );
      c := ( c xor not ( ord( EncryptKey shr cnt ) ) );
      result.Write( c, 1 );
      end;
  finally
    InMS.Free;
  end;
end;

The problem is I can’t figure out how to properly read and decrypt this on the Mac side. I’ve tried various approaches to using NSData with no success whatsoever.

Any help or suggestions would be greatly appreciated.

  • 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-29T09:55:24+00:00Added an answer on May 29, 2026 at 9:55 am

    May be this would help you (simple xor encrypting):

    -(void) decryptData :(NSMutableData *) data{
        unsigned char *bytes = (unsigned char *)malloc([data length]); 
        unsigned char magic[4] = {(currentCipher >> 24) & 0xff,(currentCipher >> 16) & 0xff,(currentCipher >> 8) & 0xff,(currentCipher) & 0xff};
        [data getBytes:bytes];
        int magic_pointer = 0;
        for (int i = 16; i < [data length]; i++) {
            bytes[i] ^= magic[magic_pointer];        
            if (magic_pointer == 3) magic_pointer = 0; else magic_pointer++;
        }
        free(bytes);
        [data setData:[NSMutableData dataWithBytes : bytes length: [data length] ]];
    }
    

    here:
    currentCipher is your EcrytpKey, ^ xor. also shift right in C is >>, not operator is !.

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

Sidebar

Related Questions

I'm working on porting a windows-only application to Linux, and eventually to Mac OSX.
For my application, I need to handle encrypted ZIP files. Despite their horrific looking
For my application, I need to handle encrypted ZIP files. Despite their horrific looking
I'm working on an OSX application (using xcode) and all the versionning stuff is
I'm working on OSX application that needs a CSS preview. I need to find
I'm currently working on a cross-platform application (Win/OSX/iOS) which has a C++ (with Boost)
I'm one step away from having my Windows .Net application working on Mac OS
I'm working on a cross platform C++ application for Windows, Mac OS X and
I'm currently working on an application which keeps tracks of cats and their associated
I'm writing a Java Swing application for the Mac using Java 1.6. I've read

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.