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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:25:08+00:00 2026-05-30T08:25:08+00:00

I have to encrypt a particular URL parameter. If I want the output to

  • 0

I have to encrypt a particular URL parameter. If I want the output to be below 6-7 characters, what algorithm should I use?

The inputs are integer only ranging from 1 to 1,000,000.

  • 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-30T08:25:09+00:00Added an answer on May 30, 2026 at 8:25 am

    If you require encryption and need to have the shortest result possible, you must use a stream cipher. Blowfish (what you previously used) is a blockcipher and the result will always have the minimum size of one single block.

    Find a comparison of stream ciphers on Wikipedia and the list of supported ciphers in the PHP manual on mcrypt

    Also, the result of the encryption may contain special chars, so when putting it into an URL as a parameter, you should use urlencode() or base64_encode()

    Using urlencode() or base64_encode() will expand your string, making it longer than the original data. This is necessary to make it transport/URL safe.

    However, since your input is always a number you can use base_convert() to shorten your input. On the decoding side, you’d have to do reverse the same thing.

    To get even shorter results, you could make use of the enminicode() / deminicode() function provided by Aron Cederholm instead of using base_convert().

    Here is an example using the RC4 stream cipher (which is not very strong, by the way) and conversion from base 10 to base 36.

    NOTE: this example only works on numbers hence its using base_convert() to shrink the input string!

    function my_number_encrypt($data, $key, $base64_safe=true, $shrink=true) {
            if ($shrink) $data = base_convert($data, 10, 36);
            $data = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $data, MCRYPT_MODE_STREAM);
            if ($base64_safe) $data = str_replace('=', '', base64_encode($data));
            return $data;
    }
    
    function my_number_decrypt($data, $key, $base64_safe=true, $expand=true) {
            if ($base64_safe) $data = base64_decode($data.'==');
            $data = @mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $data, MCRYPT_MODE_STREAM);
            if ($expand) $data = base_convert($data, 36, 10);
            return $data;
    }
    
    $data = "15231223";
    $key = "&/ASD%g/..&FWSF2csvsq2we!%%";
    
    echo "data: ", $data, "\n";
    $encrypted = my_number_encrypt($data, $key);
    echo "encrypted: ", $encrypted, "\n";
    $decrypted = my_number_decrypt($encrypted, $key);
    echo "decrypted: ", $decrypted, "\n";
    

    Result:

    data: 15231223
    encrypted: BuF3xdE
    decrypted: 15231223
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been able to use the algorithm to encrypt and decrypt files ,
I have an enCrypt and deCrypt class which I want to use in my
That's what I want to know. If I have to encrypt the cookie value
Hi All I have to encrypt my data using Blowfish algorithm in C++...can you
I have chosen an algorithm to encrypt a file. i may encrypt text or
I have to encrypt the output file in A application, then decrypt it in
I have to encrypt and decrypt a zip file using DES Algorithm by using
I have to encrypt/decrypt some sensitive information in a Xml file? Yes I can
In my project I am using custom android devices and I have to encrypt
I need to encrypt and decrypt short strings (Ex. 'product1234'). I have used mcrypt_encrypt

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.