how to detect if the barcode is for Weight Scale Item - barcode

I wonder how we can detect if a barcode that is read by barcode reader is related to an items that is sold by weight or a regular item ( in Ean-13 or other formats) ? is there any part of code that shows that it is a weighted Item?

Barcodes are just strings of characters (mostly numbers and letters) and most barcode readers/scanners do not indicate the type of barcode. They just send the value. But some values, such as an EAN13, have embedded check digits that can be used to auto-discriminate. For example, if you see a 13-digit number and calculate the mod10 check digit over the first 12 digits and it matches the 13th digit, you can be fairly certain you have an EAN13.
Alternatively, if you have control over the creation of the barcodes, you can use GS1 application identifiers to prefix each value. (GS1 barcodes can actually contain multiple values in a single symbol.) See https://www.gs1.org/standards/barcodes/application-identifiers?lang=en for more information on the standard ids. Application ids are routinely used in logistics but are fairly rare in retail channels.

Related

How to choose a barcode type

I am building a time keeping application for a business. Their staff will carry a unique barcode (either on a lanyard or as an image on their phone) and will display it to a barcode reader. The reader will use it to identify the clock-on/clock-off activity of the staff member.
As it currently stands, each staff member already has a unique id. These are incrementing integers, starting at the digit 1. At the very most, there may be hundreds or thousands of unique staff members (throughout the duration of the lifetime of my application) but certainly not one million or more. I am planning to encode this unique ID as the barcode.
Given the above, how should I choose a bar code system?
It seems to me that EAN13 is widely supported by barcode readers, and has ample 'space' for my needs (i.e. less than 1-million unique id's). This would seem like a good choice.
I see that some other systems include 'error checking', but they include a lot more visual detail. I presume that these codes would need to be printed carefully (e.g. not on a home printer), and would only useful in well lit environments.
EAN-13 uses "registered" numbers and is primarily for consumer packaging.
If you want a linear barcode, look at code128. It has a built in check-digit and packs two digits per "character". You should plan to zero-pad the numbers to 6 or 8 digits so the barcodes are always the same size. The following shows "000101" in code128:
https://bwipjs-api.metafloor.com/?bcid=code128&text=000101&includetext&backgroundcolor=ffffff
I'd choose QR codes cos they're sick, you can stick a logo in them, and they're just nice in general.

Substitution cipher decryption using letter frequency analysis for text without blanks and special characters

I need to find the plain text for given cipher text. I also have statistics (in an Excel document) for the letters in the given language e.g. I have the frequencies of the letters and also of the digraphs.
I tried this approach so far: I evaluated the frequency of each letter in the cipher text I received. Then I sorted the letters in descending order by their frequencies and mapped each letter with the corresponding letter from the Excel document. The problem with this approach is that it gives me some text that has no meaning at all. That is because my text is pretty small (only 1500 characters long).
I considered doing some limited permutations, but I have no idea what could I use to evaluate how good some permutation is. I think a good evaluation function would solve my problem.
Be aware that all special characters and white spaces are removed from the text. Also there are no numbers.
Thank you in advance.
for fully automated decryption
you need to add some dictionary of commonly used words
and compare against it
the solution that finds most words from it is probably the right one
with letter probabilities comes few problems
they are derived for common texts
so if your encrypted text is for example technical paper and not beletry ...
or it includes equations or tables
then it can screw your overall letter occurence
so do it like this:
compute the probabilities of letters
divide letters into groups by probabilities
so commonly used (high probability) letters are grouped together (group A)
so less common used (mid probability) letters are grouped together (group B)
and the rest (low probability) also group together (group C)
substitute group A
first see if group A probabilities match your language
if not then the text is in different language,style/form,or it is not a plain text at all
in such case you can not proceed safely
if they match then substitute letters from group A
they should be OK on the first run
try substitute group B
so you know all the letters from group B (encrypted/decrypted)
so generate all permutations of substitutions
for each one try to decipher text
and search for words after decryption (ignoring not yet substituted letters)
compute the word count percentage
and remember the best one (or few top ones)
try substitute group C
do it the same as bullet 4
corrections
it is probable that in the final result will be few letters mixed
so there are ways to handle also this
you can have table of letters that are mixable between each other
so you can try permutate them and test against your dictionary
or find words in your text with 1-2 wrong letters per word (for bigger words like 5 or more letters)
and permutate/correct substitution of the wrong letters if enough such words found
[notes]
you can obtain dictionaries from translators
also saw some plain text translator tables online
the groups should have distinct probability difference to each other
number of groups can change with language
I had best results for this task with semi automated approach
steps 5,6 can use user input

How does Precision and Scale work for Oracle's NUMBER data type?

If I have an ID field that is 7 characters long what do I set the scale and precision to? This is rather confusing. Or say a field of 10 characters for a phone number ... what is the S and P then?
For a series of digits such as a phone number or Social Security Number, or Zip Code, or ISBN, consider what operations you will be carrying out on it.
Will you be:
adding them together, taking the average, representing them with variable numbers of decimal places, multiplying them, etc?
Or will you be checking the length, splitting them out into a pattern, needing to preserve any leading zero, extracting a set of characters (first three, last four), comparing them to a regular expression, etc?
If the former, then they are numbers and you should store them as an integer. If the latter then they are strings constrained to be composed only of certain characters, and you should store them as a string with an appropriate check constraint.
I think at the moment you're asking something like "what temperature should my aquarium water be held at to keep cats in it"? The answer, probably, is not to do it at all, as you'll end up bitten.
For an ID, since you shouldn't need decimals, a precision of 7 and a scale of 0 would work in your case. For a phone number, you would use a varchar2 or something comparable, in which case a scale and precision wouldn't apply.
You mentioned "characters" for the ID, but I'm assuming it's numerical.
Documentation regarding scale and precision in Oracle can be found here... http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832
Specifically:
...you can also specify a precision (total number of digits) and scale (number of digits to the right of the decimal point)
Note though that precision and scale are optional and you may not even need to worry about them for something like an ID.
More examples can be found here... What is the difference between precision and scale?

Barcode reader last digit UPC-A

is it possible to have my reader read the last digit of UPC-A (CheckSum) and not write it.
(BY config)
Let's say it reads 123456789012 (2 is the checksum)
and then it writes 12345678901 without the checksum.
Thanks.
Yes it's possible. I was using the wrong manual, the readers do have configurations to show the checksum or not.
A Barcode Scanner is an input device....no different than a mouse or keyboard.
The final output is based upon whatever function is determined by your software.
The way that UPC barcodes work is, the barcode graphic is scanned, the bars are converted back to numbers and a database query is done comparing the 12-digit number represented by the bars against the 12 digit number in the database. When that item is found, the next function of the software is performed (price look-up, inventory change, etc.)
If you have a different need, you would have to write your software code to perform a different function which could be writing the first 11 digits.

python code for calculating session id randomness

I have a list of 1000 session ids. the session-id lengths are of 32 characters each. What is the most efficient algorithm which I can use to determine the randomness or variation at each character level? I am new to python, can somebody help me develop a python code snippet for the same?
Just for reference, Sequencer tool in Burpsuite gives a randomness graph for each 10 character positions if the token length is 10 characters. (algorithm is unknown to me)
I don't know how Burp does it but one way to determine the variation at each character level would be to do character frequency analysis for each position in the session ids.
The premise is that you'd expect that all character are equally likely to appear at a position across all session ids (the distribution of characters is uniform). Let's say you have collected/generated 100 session ids which are numeric (so possible characters at each position would be 0-9) you'd expect that each digit would appear 100/10=10 times at each position.
Now for each position in the sequences build a histogram with how many time a character actually appears at that position across all session ids.
To figure out how likely is your observed character distribution at each position given that you'd expect them to be uniformly distributed you can use a statistical test like the Chi Squared test.
I've written a simple Python character count tester using the Chi Squared test here: https://github.com/decbis/salr. I'll add more tests in the future.

Resources