C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 1st, 2002, 08:30 AM
converge converge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 2 converge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to encode a 7 character long string into a 5 character long string

I have a series of strings that are 7 characters long each. My problem is this: these strings contain important product information that needs to be encoded. However these strings need to be encoded into 5 character long strings and encoded in such a way that just by reading the string values don't give away valuable information. The process needs to be reversable (convert the encoded 5 character long strings into 7 characters long). Thanks.

Reply With Quote
  #2  
Old August 1st, 2002, 09:55 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,442 Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level)Scorpions4ever User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 h 49 m 40 sec
Reputation Power: 797
This might actually be a question to be asked in the algorithm forum, but I'll try to answer it here. It's possible to do this, provided you give some information about what the possible range of characters is in the 7 character string.

Assuming that the characters used are only A-Z (uppercase or lowercase alone) and maybe a few other characters like space, comma, period etc. here's how I'd do it.

We have to compress our data into a 5 byte array. Therefore we have 5 Bytes = 40 bits (because each byte = 8 bits)

Assume a 5 bit baudot character set. This means that 5 bits will be used to represent each character, so there can be a maximum of 2^5 = 32 characters in this set. A-Z will take up 26 of these characters, leaving 6 free characters which you can use for characters such as space, period, comma and three other characters of your choosing. Now, if each character uses up 5 bits, then to represent 7 characters in this set, you'll need (7 x 5) = 35 bits

Therefore, you can squeeze 7 characters into a 5 byte array using this 5 bit character set. Matter of fact, you can squeeze an 8th character in there as well, or use the remaining 5 bits for status, parity or checksum bits of some sort. Does this give you an idea how to proceed?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > how to encode a 7 character long string into a 5 character long string


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway