Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I want to encode one string to 16 character string which is composite from different numeric digits as below (A, B, C etc..) and it should be decodable also so get all the information back.

For example :
A = any number between 0 to 99999 (21923)
B = any number between 0 to 99999 (12045)
C = any number between 0 to 99999 (29433)
D = any number between 0 to 99999 (12003)
E = any number between 0 to 99999 (234)
F = any number between 0 to 99999 (189)
.
.
J = any number between 0 to 99999 (189)

This can be possible upto J. but G, H, I and J are optional.

Z = A#B#C#D#E#F
Z = 21923#12045#29433#12003#234#189

Now by doing any encode operation on string Z, result string want to maintain upto 16 characters and it should be decodable so able to get the above all part (eg. A, B, C etc...) same as it is assigned.

Also Result string should be contain only 0-9 and capital character of Alphabet (A-Z)

I have tried to convert each part (eg. A, B C etc .) to Hex number and conctate it but I am not able to restrict the length upto 16 character which is reverse decodable to get original information.

so can any one help me or give hint to achieve this thing.

Thanks,
Posted
Updated 5-Feb-14 17:15pm
v2
Comments
Sergey Alexandrovich Kryukov 5-Feb-14 23:27pm    
Very naive compression. Why? And why should anyone implement your idea? This is not even a question; you did not even pose any problem.
By the way, compression algorithms should really compress abstract data, byte[]. And string data depends on encoding.
—SA

1 solution

Please see my comment to the question.

Also consider this: not every string can be compressed to 16-character string. And those which can does not deserve to be compressed. Besides, even if you "compress" something, compression factor is ridiculously small. You can even make "compressed" string taking up more memory than uncompressed. Overall, it makes no sense at all.

—SA
 
Share this answer
 
Comments
npdev13 5-Feb-14 23:48pm    
Yes, thanks for comment. I was just confused, this type of compression possible or not
Sergey Alexandrovich Kryukov 6-Feb-14 1:09am    
This is not a comment, this is an answer. It would be safe to say, this type of compression is not worth considering.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900