# ============ # CueCatDecode # ============ # # Arguments: 1 - output from CueCat scanner # # Returns: An array, structured like this: # $array[0] = CueCat ID # $array[1] = Type of barcode # $array[2] = Barcode data # # Example: # # my $data=<STDIN>; # my @barcode=CueCatDecode($data); # print "ID: $barcode[0]\n"; # print "TYPE: $barcode[1]\n"; # print "BARCODE: $barcode[2]\n"; # sub CueCatDecode { my($cuecat_output)=@_; my $len; my $i; my $c; # Lets Split our CuCat String into a Array with all the differnt s +ubsections my @scanned_data=split /\./,$cuecat_output; # Swap upper case to lower case and vice versa, minuses to slashes my $id = $scanned_data[1]; $id =~ tr|A-Za-z\-|a-zA-Z/|; $id =~ tr|A-Za-z0-9+/| -_|; # convert to uuencode format $len = chr(32+length($id)*3/4); # compute length byte $id = unpack("u", $len . $id); # uudecode my $barcode_type = $scanned_data[2]; $barcode_type =~ tr|A-Za-z\-|a-zA-Z/|; $barcode_type =~ tr|A-Za-z0-9+/| -_|; # convert to uuencode +format $len = chr(32+length($barcode_type)*3/4); # compute length byte $barcode_type = unpack("u", $len . $barcode_type); # uudecode my $barcode = $scanned_data[3]; $barcode =~ tr|A-Za-z\-|a-zA-Z/|; $barcode =~ tr|A-Za-z0-9+/| -_|; # convert to uuencode forma +t $len = chr(32+length($barcode)*3/4); # compute length byte $barcode = unpack("u", $len . $barcode); # uudecode # Take each character XOR 67 my $decrypt_id=''; for ($i=0;$i<length($id);$i++) { $c = substr($id,$i,1); $decrypt_id = $decrypt_id . chr(ord($c) ^ 67); } my $decrypt_type=''; for ($i=0;$i<length($barcode_type);$i++) { $c = substr($barcode_type,$i,1); $decrypt_type = $decrypt_type . chr(ord($c) ^ 67); } my $decrypt_barcode=''; for ($i=0;$i<length($barcode);$i++) { $c = substr($barcode,$i,1); $decrypt_barcode = $decrypt_barcode . chr(ord($c) ^ 67); } my @decrypted_barcode=(); push(@decrypted_barcode,$decrypt_id); push(@decrypted_barcode,$decrypt_type); push(@decrypted_barcode,$decrypt_barcode); return @decrypted_barcode; }
In reply to CueCat Decoding Sub by #include
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |