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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:08:18+00:00 2026-05-31T18:08:18+00:00

I want to develop something similar to jsfiddle in where the user can input

  • 0

I want to develop something similar to jsfiddle in where the user can input some data and then “save” it and get a unique random looking url that loads that data.

I don’t want to make the saves sequential because I don’t want anyone to grab all of my entries, as some can be private. However on the server I would like to save it in sequential order.

Is there a function or technique that converts a number into a hash that has 4 charactors without any collisions until (62 * 62 * 62 * 62 === 14776336) entries?

For example the first entry on the server will be named 1 on the server but iUew3 to the user, the next entry will be 2 on the server but ueGR to the user…

EDIT: I’m not sure if it’s obvious but this hash-like function needs to be reversible because when the user requests ueGR the server needs to know to server it file 2

  • 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-31T18:08:19+00:00Added an answer on May 31, 2026 at 6:08 pm

    It’s possible to do this, but I would suggest using 64 characters, as that will make it a lot easier. 4 6bit characters = 24bits.

    Use a combination of these:

    • bit reordering
    • xor with a number
    • put it into a 24bit maximal length LFSR and do a couple of cycles.

    LFSR is highly recommended as it will do a good scrambling. The rest are optional. All of these manipulations are reversible and guarantee that each output is going to be unique.

    When you calculated the “shuffled” number simply pack it to a binary string and encode it with base64_encode.

    For decoding simply do the inverse of these operations.

    Sample (2^24 long unique sequence):

    function lfsr($x) {
        return ($x >> 1) ^ (($x&1) ? 0xe10000 : 0);
    }
    function to_4($x) {
        for($i=0;$i<24;$i++)
            $x = lfsr($x);
        $str = pack("CCC", $x >> 16, ($x >> 8) & 0xff, $x & 0xff);
        return base64_encode($str);
    }
    
    function rev_lfsr($x) {
        $bit = $x & 0x800000;
        $x = $x ^ ($bit ? 0xe10000 : 0);
        return ($x << 1) + ($bit ? 1 : 0);
    }
    function from_4($str) {
        $str = base64_decode($str);
        $x = unpack("C*", $str);
        $x = $x[1]*65536 + $x[2] * 256 + $x[3];
        for($i=0;$i<24;$i++)
            $x = rev_lfsr($x);
        return $x;
    }
    
    for($i=0; $i<256; $i++) {
        $enc = to_4($i);
        echo $enc . " " . from_4($enc) . "\n";
    }
    

    Output:

    AAAA 0
    kgQB 1
    5ggD 2
    dAwC 3
    DhAH 4
    nBQG 5
    6BgE 6
    ehwF 7
    HCAO 8
    jiQP 9
    +igN 10
    aCwM 11
    EjAJ 12
    gDQI 13
    9DgK 14
    ZjwL 15
    OEAc 16
    qkQd 17
    3kgf 18
    TEwe 19
    NlAb 20
    pFQa 21
    0FgY 22
    
    ...
    

    Note: for URL replace + and / with - and _.

    Note: although this works, for a simple scenario like yours it’s probably easier to create a random filename, till it doesn’t exist. nobody cares about the number of the entry.

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

Sidebar

Related Questions

I want to develop a process() method. The method takes some data in the
I want develop a system where I can transfer some images and after run
I want to develop an application for WP7 using HTML,CSS and Javascript something Similar
I want to develop an application for the android platform that can download some
I want to develop simple Serverless LAN Chat program just for fun. How can
I want to develop a mobile web application using asp.net 3.5 that can be
I want to develop an application that disables the Background Data (new feature in
I'm asking for some orientation and recommendations for developing something similar like the yahoo
I want to develop something like the home screen of the Android's devices, where
I want to develop an iPhone app that read data from the internet but

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.