in reply to Re: convert hexadecimal value to encrypted string
in thread convert hexadecimal value to encrypted string

I have an encryption server that encrypts this data and writes this to a table in the database. I can extract data from the database and then send it in a request to the server so that it can give back me the plain text(this is what I am trying to do right now).

The data is stored as a hex string in the database table. I want to convert it back to a "regular string" and am unable to find the right conversion string using pack/unpack. I hope this makes my question clearer.

Thanks!

  • Comment on Re^2: convert hexadecimal value to encrypted string

Replies are listed 'Best First'.
Re^3: convert hexadecimal value to encrypted string
by diotalevi (Canon) on Dec 11, 2004 at 02:50 UTC
    You'll need to send the data back to the encryption server and have it decrypt it.
      That is what I am trying to do. In order to send the data back to the encryption server, I need to read it from the database first, create a request and then send it to the server.

      The problem I am seeing right now is that the data I have extracted from the database is in Hex format like the string I posted earlier (639D879F224CA2A1BA73CC4884DBD362) and the server does not recognize this as a valid cipher text (sending a request with this string results in error). That is the reason I wish to convert the hex string to a "string format" using pack/unpack so that I can send the "correct" ciphertext to the server. IMHO, a conversion of the hex number to a regular string should work.

      Thanks!

        Aha. I see. When I tried to pack your string I noticed that perl thought that it was being given unicode data and treated it accordingly. Instead of plain pack "H*", $str, try do { use bytes; pack "H*", $str }. See bytes for more on forcing perl to not try to interpret it as unicode.

        Oh further drat. when I wrote that I saw things like \323 and thought "aha! a value over 255, obviously unicode." Unfortunately for me, that was an octal number and this whole digression on unicode is entirely unrelated. So, show us the value produced by the encryption server and the value fetched from the database. As-is, there isn't anything that you're doing wrong.