printing encrypted byte array to a barcode and scan
-
I need to print encrypted customer details as a barcode. then need to scan the data and read back the details. My approch is like this, I encrypted the string data using cryptoservices and get memory stream and sen the byte array data as unmanaged byte arra to the printer. Byte[] bytes = memoryStream.GetBuffer(); IntPtr pUnmanagedBytes = new IntPtr(0); int nLength; nLength = Convert.ToInt32(memoryStream.Length); pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength); Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength); PrintDirect.WritePrinter1(lhPrinter, pUnmanagedBytes, nLength, out pcWritten); How can I read this data back to managed byte array from the scan device. (BTW am I in the correct path.)
-
I need to print encrypted customer details as a barcode. then need to scan the data and read back the details. My approch is like this, I encrypted the string data using cryptoservices and get memory stream and sen the byte array data as unmanaged byte arra to the printer. Byte[] bytes = memoryStream.GetBuffer(); IntPtr pUnmanagedBytes = new IntPtr(0); int nLength; nLength = Convert.ToInt32(memoryStream.Length); pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength); Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength); PrintDirect.WritePrinter1(lhPrinter, pUnmanagedBytes, nLength, out pcWritten); How can I read this data back to managed byte array from the scan device. (BTW am I in the correct path.)
What is PrintDirect ? Is it a class for printing barcodes ? I'd assume that the same class would know how to return a byte array from the barcode it created ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
What is PrintDirect ? Is it a class for printing barcodes ? I'd assume that the same class would know how to return a byte array from the barcode it created ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
PrintDirect.writePrinter - normal pront command to write data to the printer. Theres a scan divice configured to a com port to scan the barcode. When i scan the barcode I need to read that data (that I send as unmanaged byte array to the printer). and decrypt it and get the initial customer details.
-
PrintDirect.writePrinter - normal pront command to write data to the printer. Theres a scan divice configured to a com port to scan the barcode. When i scan the barcode I need to read that data (that I send as unmanaged byte array to the printer). and decrypt it and get the initial customer details.
OK, so you have two problems 1 - write a barcode that your scanner can read back 2 - read it back Assuming you got 1 right, 2 should just be a case of using the APIs provided by the scanner.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
OK, so you have two problems 1 - write a barcode that your scanner can read back 2 - read it back Assuming you got 1 right, 2 should just be a case of using the APIs provided by the scanner.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
everything works fine if I send my data as a string (print the barcode and read it back). Problem occures when I print it as an unmanaged byte array. Is there any way that I can send byte by byte to the printer and when scan it read byte by byte. Can anybody help me.
-
everything works fine if I send my data as a string (print the barcode and read it back). Problem occures when I print it as an unmanaged byte array. Is there any way that I can send byte by byte to the printer and when scan it read byte by byte. Can anybody help me.
REalistically, we're just stabbing in the dark, because we have no idea what bar code system/scanner you are using. You may be hitting a limitation of the SDK, if you're finding a way to write a barcode, but that barcode cannot be read back.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
everything works fine if I send my data as a string (print the barcode and read it back). Problem occures when I print it as an unmanaged byte array. Is there any way that I can send byte by byte to the printer and when scan it read byte by byte. Can anybody help me.
Hi, I expect a barcode printer to accept printable text only, not just arbitrary bytes. It probably will have trouble with non-printable characters. One possible solution could be to use an encoding such as base64 (which replaces a number of bytes by a greater number of ASCII-printable bytes, about 4 four 3). Have a look at Convert.ToBase64String and Convert.FromBase64String :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
-
Hi, I expect a barcode printer to accept printable text only, not just arbitrary bytes. It probably will have trouble with non-printable characters. One possible solution could be to use an encoding such as base64 (which replaces a number of bytes by a greater number of ASCII-printable bytes, about 4 four 3). Have a look at Convert.ToBase64String and Convert.FromBase64String :)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
yes, the printer doesn't seems like accepting some characters. I've solved the problem by using different encryption/decryption method with no overhead (abandon the dot net cryptoservice ). Thanks alot for your comments. they help me to find the correct path.