Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**zxcvbnm123****Member**- Registered: 2013-05-08
- Posts: 15

Lets say i have a value 545388669453 i need to use a algorithm to convert the value to a 6 digit value. then i enter the 6 digit value on the other application. the other application will use the same algorithm to get back the value of 545388669453.

is there such algorithm? please help me

Offline

**SteveB****Member**- Registered: 2013-03-07
- Posts: 594

You have posted a number which contains 12 digits which I presume are from the set {0,1,2,3,4,5,6,7,8,9}

If you are trying to put that into 6 digits then you would have to do something like put them into pairs somehow such as

With 123456789123 put that into 12,34,56,78,91,23

Then find a way of mapping all of the numbers from 00 to 99 (100 of these in total) onto characters to replace them.

You would then need 100 different individual characters to do this !!

There are enough ASCII characters to do this. I do not have up to date knowledge of this because my hobbyist knowledge of the

ASCII character character set comes from about 2 to 3 decades ago. (It was first used in 1963 according to wikipedia)

With the letters of the alphabet you have 26 characters which can be lower or upper case. (52 in total)

You do of course have the 10 digits. That makes 62. Then there are punctuation characters - I'm not sure how many exactly.

With the ASCII set there are 128 characters. It might be an idea to google the term to find out about it.

So perhaps some mapping from the 100 double digit numbers to these could be worked out.

You could then map from the 12 digits to your chosen character set and then back again without losing information.

*Last edited by SteveB (2013-07-26 18:07:43)*

Offline

**zxcvbnm123****Member**- Registered: 2013-05-08
- Posts: 15

i forgot to add that the value is actually a encrypted value which is not in fixed length, and the position of the digit cannot be sorted as i will lose information.

is there any kind of fix algorithm something like (mod 1000)*6 /2. that kind of algorithm to change it to 6 digit value and able to get back the actual value on the other side.

Offline

**SteveB****Member**- Registered: 2013-03-07
- Posts: 594

How many possible values of the 12 digit number could there be ?

If it is an integer from 0 to 999999999999 then there are 10^12 that is one billion possible numbers.

If you replace them with an integer from 0 to 999999 there are only 10^6 or only one million possible numbers.

It would be impossible to do this without information loss.

However I suppose if your encryption means that the 12 digit number is not fully used then it is possible,

provided there is deliberate redundancy in the digit usage.

Without more details of the original number it would not be possible to program this because otherwise you

would map two 12 digit numbers onto the same 6 digit number and not know how to restore the original.

There is a topic I studied about 11 years ago called "graphs networks and design" in which the design part

included a topic on codes. In this topic you could pad a set of digits out with extra information do that you could

both check and in some cases correct digits and still have them coded in some way so the information was not

obvious to someone gaining the information who should not do so. I do not have the book handy, but it might

be about somewhere. I think maybe the 12 digit number has deliberate padding of this kind, but one would need

to know how that had been done in order to decode it back to the 6 digit form. Otherwise it would not be a good code.

You can of course try to discover the code, but I presume you wrote it?

*Last edited by SteveB (2013-07-26 19:13:46)*

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Hi zxcvbnm123;

How secure does it have to be? There might be a unique algorithm that will map your numbers to a unique number with no hash collisions.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**SteveB****Member**- Registered: 2013-03-07
- Posts: 594

If it does have to be secure then it would not be possible for zxcvbnm123 to post the details so we could have a problem here !

I will leave it to others from here, so feel free to take over bobbym, I think this might be more your area.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 109,606

Hi SteveB;

I am not sure what he asks is possible.

If it must be mapped to the digits 0 - 9 then there is clearly a problem. If we are allowed higher bases then 10 for instance

The base 36 digit number only requires 8 digits in its base. Higher bases would give the required 6 digits (character ) answer.

That is, if he will allow that?!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

**SteveB****Member**- Registered: 2013-03-07
- Posts: 594

Yes I think my answer was essentially a "base 100" system that I had in mind. I don't really consider it possible otherwise.

However if there were for instance a check digit after each proper digit in the original 12 digit code then it would be possible,

but we need exact details of what and how the 12 digit number was created to be able to do this.

Offline

**zxcvbnm123****Member**- Registered: 2013-05-08
- Posts: 15

i am using rsa encryption formula to get the values

does knowing how i get the long value really helps? the condition is the encrypted value length is not fix, it can be 12 digit long, it can be 25 digit long. and the position of the value must not be changed.

*Last edited by zxcvbnm123 (2013-07-26 21:28:51)*

Offline

**SteveB****Member**- Registered: 2013-03-07
- Posts: 594

If you have 26 letters of the alphabet then each of these has 26 possible values.

If my calculations are correct then you have 11881376 (26^5) values with a 5 letter word converted.

Unfortunately if you want to squash these into only 6 digits from 0 to 999999 using only numbers then there are only 1000000

numbers available to use. This needs to be just under 12 times higher to work.

If the length of the data is unbounded then obviously it is not possible because you need unlimited digital space to store it.

I think you would have to set a limit of 4 letters for a word and then map that to a set of 6 numeric digits.

This would then at least be possible, but programming that could be confusing.

However in the case I have stated of using a maximum of 4 alphabetic letters for 6 numeric digits it can be done.

*Last edited by SteveB (2013-07-26 20:31:43)*

Offline