Tool to decrypt Barcode 39. Code 39 (or Code 3 of 9 or Alpha39) is a normalized barcode system which is being replaced by Code 128.
Barcode 39 - dCode
Tag(s) : Character Encoding, Image Processing
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Encryption uses an encoding table with 43 characters: the 26 capital letters, the 10 digits and some special characters (-, ., $, /, +, % and ' ' (space). The character * can appear but it does not exist, it is only used as a delimiter for start and end.
Each character has 5 black bars and 4 white bars (9 elements in total) starting with black and alternating white and black. Each band can have 2 widths: narrow or wide (generally 3 times larger), so it is possible to binarize the code (1 for thin bands, and 0 for wide bands). Also, in these 9 elements, always 3 bands are larger, hence the name of code 39.
A barcode 39 starts with * and ends with *. Here is the character map:
Each character has 5 black bars and 4 white bars (9 elements in total), it is therefore possible to binarize the (1, 11 or 111 for black bands according to its width, 0, 00 or 000 for white bands). In these 9 elements there are 3 which are larger (between 2 and 3 times as wide) and 6 thinner. The code starts with * and ends with *.
0 | |||▮▮|▮|| | 1 | ▮||▮||||▮ |
2 | ||▮▮||||▮ | 3 | ▮|▮▮||||| |
4 | |||▮▮|||▮ | 5 | ▮||▮▮|||| |
6 | ||▮▮▮|||| | 7 | |||▮||▮|▮ |
8 | ▮||▮||▮|| | 9 | ||▮▮||▮|| |
A | ▮||||▮||▮ | B | ||▮||▮||▮ |
C | ▮|▮||▮||| | D | ||||▮▮||▮ |
E | ▮|||▮▮||| | F | ||▮|▮▮||| |
G | |||||▮▮|▮ | H | ▮||||▮▮|| |
I | ||▮||▮▮|| | J | ||||▮▮▮|| |
K | ▮||||||▮▮ | L | ||▮||||▮▮ |
M | ▮|▮||||▮| | N | ||||▮||▮▮ |
O | ▮|||▮||▮| | P | ||▮|▮||▮| |
Q | ||||||▮▮▮ | R | ▮|||||▮▮| |
S | ||▮|||▮▮| | T | ||||▮|▮▮| |
U | ▮▮||||||▮ | V | |▮▮|||||▮ |
W | ▮▮▮|||||| | X | |▮||▮|||▮ |
Y | ▮▮||▮|||| | Z | |▮▮|▮|||| |
- | |▮||||▮|▮ | . | ▮▮||||▮|| |
|▮▮|||▮|| | $ | |▮|▮|▮||| | |
/ | |▮|▮|||▮| | + | |▮|||▮|▮| |
% | |||▮|▮|▮| | * | |▮||▮|▮|| |
A wide band is 3 times thicker than a thin band.
Example: A narrow black band would be coded 1 and a wide black band would be coded 111.
Example: *A* is coded |▮||▮|▮||▮||||▮||▮ |▮||▮|▮|| or in binary 1 000 1 0 111 0 111 0 1 0 111 0 1 0 1000 1 0 111 0 1000 1 0 111 0 111 0 1 0
Decryption requires to perform a reading of the bar according to EAN-128 standard.
Many app for smartphones or laser handshowers facilitate this work.
Example: The message is |▮||▮|▮|| ||||▮▮||▮ ▮|▮||▮||| ▮|||▮||▮| ||||▮▮||▮ ▮|||▮▮||| |▮||▮|▮|| (alternating black and white stripes), check |▮||▮|▮|| at the beginning and the end to confirm it's a code 39 barcode. The replacement of each 9-bar group by their associated character in the table. Barcode value is DCODE.
Checksum is missing in this example
Associate with each character the value of its position in the alphabet of 43 characters 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+% * (starting from 0)
Add these values and calculate the result modulo 43. The control character is the one in position (sum%43) in the alphabet.
The barcode has a classic graphical form (black and white lines) or a binary equivalent (1 or B for black and 0 or W for white lines).
The barcode may have a variable length. It begins and ends with the character *.
The bar code consists of lines in groups of 9 which 3 are wider, hence the name 3 of 9 or 39.
dCode retains ownership of the "Barcode 39" source code. Except explicit open source licence (indicated Creative Commons / free), the "Barcode 39" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Barcode 39" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Barcode 39" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Barcode 39" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Barcode 39 on dCode.fr [online website], retrieved on 2024-12-04,