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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:06:43+00:00 2026-05-14T05:06:43+00:00

I have a few issues with the following php functions (part of a bigger

  • 0

I have a few issues with the following php functions (part of a bigger class).

    //encode
    public function acc_pw_enc($text, $key) {
    $text_num = str_split($text, 8);
    $text_num = 8 - strlen($text_num[count($text_num)-1]);

    for ($i=0; $i < $text_num; $i++) {
        $text = $text . chr($text_num);
    }

    $cipher = mcrypt_module_open(MCRYPT_TRIPLEDES, '', 'cbc', '');
    mcrypt_generic_init($cipher, $key, 'fYfhHeDm');
    $decrypted = mcrypt_generic($cipher, $text);
    mcrypt_generic_deinit($cipher);
    return base64_encode($decrypted);
}

    //decode
public function acc_pw_dec($encrypted_text, $key) {
    $cipher = mcrypt_module_open(MCRYPT_TRIPLEDES, '', 'cbc', '');
    mcrypt_generic_init($cipher, $key, 'fYfhHeDm');
    $decrypted = mdecrypt_generic($cipher, base64_decode($encrypted_text));
    mcrypt_generic_deinit($cipher);
    $last_char = substr($decrypted, -1);

    for($i=0; $i < 8-1; $i++) {
        if(chr($i) == $last_char) {      
            $decrypted = substr($decrypted, 0, strlen($decrypted)-$i);
            break;
        }
    }
    return rtrim($decrypted); //str_replace("?", "", $decrypted);
}

So for exampe if i encrypt the string ‘liloMIA01’ with the salt/key ‘yBevuZoMy’ i will get ‘7A30ZkEjYbDcAXLgGE/6nQ==’.

I get liloMIA01 as the decrypted value, i tried using rtrim but it didn’t work.

  • 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-14T05:06:43+00:00Added an answer on May 14, 2026 at 5:06 am

    A big problem with mcrypt is it doesn’t support any padding algorithm when used with block ciphers like 3DES. So you will get garbage at the end if the data is not multiple of block size (8 bytes in this case).

    You need to pad the data properly using pkcs#5 or add a length field.

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

Sidebar

Related Questions

I have a few some strange issues with my class after migrating from JDK5/Tomcat5
Hi i am new to hibernate technology and i have few issues. Suppose if
I have a few weird issues I need to solve. First, let me show
I have a few routing issues with my ASP.NET MVC2 website and was wondering
So far, so good. However, a few issues have arisen. First and foremost, is
The following code is from a tutorial ( http://net.tutsplus.com/php/creating-a-php5-framework-part-1/ ), not mine. I have
The following site: http://staging.jungledragon.com Has a few rendering issues on the iPad using Safari,
Consider the following: incl.php <div id='footer'> <?php sleep(10); echo <div class='footer-float'><!-- content --></div>; ?>
Possible Duplicate: The ultimate clean/secure function I have run into a few problems with
I have seen a few posts regarding this issue but not one specific to

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.