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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:41:30+00:00 2026-05-26T09:41:30+00:00

I have to convert an old encrypted data to a proper encryption algorithm from

  • 0

I have to convert an old “encrypted” data to a proper encryption algorithm from an old system. I have this code:

 function unpackString($s,$l){
      $tmp=unpack('c'.$l,$s);
      $return=NULL;
      foreach($tmp as $v){
          if($v>0){
              $return.=chr($v);
          }
      }
      return $return;
  }
  function packString($s,$l){
      $return=NULL;
      for($i=0;$i<$l;$i++){
          $return.=pack('c',ord(substr($s,$i,1)));
      }
      return $return;
  }

  $string='StackOverflow Is AWESOME';
  $l=strlen($string);

  $encoded=packString(base64_encode($string),$l);
  $decoded=base64_decode(unpackString($encoded,$l));


  echo "\n".$decoded."\n";

Why the output shows StackOverflow Is A and not StackOverflow Is AWESOME

  • 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-26T09:41:30+00:00Added an answer on May 26, 2026 at 9:41 am

    base64 encoding expands the size of a string by about 33%. You’re passing in the length of the ORIGINAL string, not the base64 encoded one:

    StackOverflow Is AWESOME  - 24 chars plaintext
    U3RhY2tPdmVyZmxvdyBJcyBBV0VTT01F - 32 chars base64 encoded
    

    So you’re chopping off 8 characters, leaving you with

    U3RhY2tPdmVyZmxvdyBJcyBB
    

    which decodes to

    StackOverflow Is A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does PHP have any standard function(s) to convert Unicode strings to plain, good old-fashioned
I have this problem where I switched CMS from the old one to the
I have a old code in VB.Now I convert it into vb.net.There is a
I have inherited some old code and need to convert to the latest schema
I have to convert several full PAL videos (720x576@25) from YUV 4:2:2 to RGB,
I have a date like this:- 20091023 i have to convert it to a
To use such great function as ConvertAll() , I have to convert IList to
Is there a way to convert table entries from an old table to a
Possible Duplicate: C# Cannot convert from IEnumerable<Base> to IEnumerable<Derived> I have D1 and D2
I have some old code that I'm converting to use in Windows Phone. 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.