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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:12:35+00:00 2026-05-27T16:12:35+00:00

I need to work out a decryption/encryption algorithm, but I’m confused regarding SHA256 /

  • 0

I need to work out a decryption/encryption algorithm, but I’m confused regarding SHA256 / CBC / Salt / IV etc.

An example of a correctly encrypted string is:

U2FsdGVkX19IfIZtJ/48wk8z3ZRGDK8RD8agyQRhMrsOMsoIlVEcrzraOLo5IRBXjDkN1JUFnNrkvi2NA22IOTv00U97065tUNBQKEVXcaL0UJirtcqHlq8lN4pEm14ZokKXv8mUP8GkUKrOf37GhOugi/F/CQiILb57kIPrYPk=

It is Base64 encoded then Rijndael encoded. The first 8 characters are ‘Salted__’ and the next 8 characters I assume is some sort of salt (randomly generated).

The key I provided to encrypt this data is ‘12345678’.

The decrypted data should be:

2358442189442905:ZGF2aWQ=:1324515293:1.9.12:1:MC4wLjAuMCxub25lLzA=:LfcTMMYyUcwgL8keu3sMoNC/PFEKZy8fWFvo3rJvSdo

Apparently it is following Crypt::CBC::VERSION 2.29

I can’t seem to decrypt the correctly encrypted string above. I have tried the following:

NSString *key = @"12345678";

NSData *test = [NSData dataFromBase64String:@"U2FsdGVkX19IfIZtJ/48wk8z3ZRGDK8RD8agyQRhMrsOMsoIlVEcrzraOLo5IRBXjDkN1JUFnNrkvi2NA22IOTv00U97065tUNBQKEVXcaL0UJirtcqHlq8lN4pEm14ZokKXv8mUP8GkUKrOf37GhOugi/F/CQiILb57kIPrYPk="];

unsigned char salt[8]; //get the salt out
[test getBytes:salt range:NSMakeRange(8, 8)];
NSData *saltData = [NSData dataWithBytes:salt length:8];

unsigned char data[128-16]; // remove the Salted__ and the 8 character salt
[test getBytes:data range:NSMakeRange(8, 128-8)];
test = [NSData dataWithBytes:data length:128-8];

NSMutableData *aeskey = [NSMutableData dataWithData:[key dataUsingEncoding:NSUTF8StringEncoding]];
[aeskey appendData:saltData]; // add the salt to the end of the key?

NSData *test2 = [test decryptedAES256DataUsingKey:key error:nil]; //Using a NSData+CommonCrypto library

Any ideas on how to decrypt this properly?

EDIT: more information: this is code related to what I am trying to implement.

elsif ($header_mode eq 'salt') {
$self->{salt} = $self->_get_random_bytes(8) if $self->{make_random_salt};
defined (my $salt = $self->{salt}) or croak "No header_mode of 'salt' specified, but no salt value provided"; # shouldn't happen
length($salt) == 8 or croak "Salt must be exactly 8 bytes long";
my ($key,$iv) = $self->_salted_key_and_iv($self->{passphrase},$salt);
$self->{key}  = $key;
$self->{civ}  = $self->{iv} = $iv;
$result  = "Salted__${salt}";
}

  my $self = shift;
  my ($pass,$salt)  = @_;

  croak "Salt must be 8 bytes long" unless length $salt == 8;

  my $key_len = $self->{keysize};
  my $iv_len  = $self->{blocksize};

  my $desired_len = $key_len+$iv_len;

  my $data  = '';
  my $d = '';

  while (length $data < $desired_len) {
    $d = md5($d . $pass . $salt);
    $data .= $d;
  }
  return (substr($data,0,$key_len),substr($data,$key_len,$iv_len));

Here is an implementation that I don’t fully understand: http://pastebin.com/R0b1Z7GH http://pastebin.com/aYWFXesP

  • 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-27T16:12:36+00:00Added an answer on May 27, 2026 at 4:12 pm
    unsigned char salt[8]; //get the salt out
    [test getBytes:salt range:NSMakeRange(8, 8)];
    NSData *saltData = [NSData dataWithBytes:salt length:8];
    
    unsigned char data[128-16]; // remove the Salted__ and the 8 character salt
    [test getBytes:data range:NSMakeRange(8, 128-8)];
    test = [NSData dataWithBytes:data length:128-8];
    

    I think in your second block of code you are copying the wrong data. Try this:

    unsigned char data[128-16]; // remove the Salted__ and the 8 character salt
    [test getBytes:data range:NSMakeRange(16, 128-16)];
    test = [NSData dataWithBytes:data length:128-16];
    

    Your comment indicates that you want to skip both the Salted__ and the salt itself.

    Note that I haven’t got a clue where the salt should go — that’s up to the protocol that you’re trying to integrate with — so I hope you’ve got that well-documented from another source.

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

Sidebar

Related Questions

I'm trying to work out what regular expression I would need to change this
I need to work out how many different instances occur on a different day,
I need to work with MSMQ (Microsoft Message Queuing). What is it, what is
I need to work with array from several threads, so I use CRITICAL SECTION
I need to work with some old C++ code that was developed in Visual
I need to work with a third-party Java library from .NET. Can anyone recommend
I need to work with large files and must find differences between two. And
I need to work on C++ project on my windows machine. My project will
I need to work around a Java bug in JDK 1.5 which was fixed
I need to work with an old repository, whose db/format contains 2 From this

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.