# ============ # 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=; # 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 subsections 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 format $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