G
Guest
Apologies if this is a noob question, but I've been struggling with this for quite a while...
I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string that is displayed in a text box. Once displayed, the text will be copied, transmitted and then pasted (all manually by humans) into a second utility where the string must then be reverse-engineered into the *original* byte array. The byte array will then be decrypted by the second app.
I've got the encryption/decryption piece sorted, I'm just struggling with the screen-printable text bit...
I've tried many of the suggestions posted on the web for converting the byte array into a screen-printable string. All have worked, and I've settled on the following:
Dim Bytes() As Byte = myCrypto.Encrypt("AuthCode") ' .Encrypt returns a byte array
Dim myBitConverter As BitConverter
txtBox.Text = myBitConverter.ToString(Bytes)
' Displayed as XX-XX-XX-XX... in the txtBox.
The problem is that for all of the examples I've found on the internet, none have helped me reverse engineer the screen-printable string into the original byte array. Although I like the BitConverter.ToString format (XX-XX-XX-XX) used in the code above, I don't really care how the string looks - as long as it is screen-printable and can be displayed, copied, emailed and pasted without issue. Can you enlighten me as to how I can easily convert a byte array to a screen-friendly string and then back again?
Many thanks in advance.
Bryan
I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string that is displayed in a text box. Once displayed, the text will be copied, transmitted and then pasted (all manually by humans) into a second utility where the string must then be reverse-engineered into the *original* byte array. The byte array will then be decrypted by the second app.
I've got the encryption/decryption piece sorted, I'm just struggling with the screen-printable text bit...
I've tried many of the suggestions posted on the web for converting the byte array into a screen-printable string. All have worked, and I've settled on the following:
Dim Bytes() As Byte = myCrypto.Encrypt("AuthCode") ' .Encrypt returns a byte array
Dim myBitConverter As BitConverter
txtBox.Text = myBitConverter.ToString(Bytes)
' Displayed as XX-XX-XX-XX... in the txtBox.
The problem is that for all of the examples I've found on the internet, none have helped me reverse engineer the screen-printable string into the original byte array. Although I like the BitConverter.ToString format (XX-XX-XX-XX) used in the code above, I don't really care how the string looks - as long as it is screen-printable and can be displayed, copied, emailed and pasted without issue. Can you enlighten me as to how I can easily convert a byte array to a screen-friendly string and then back again?
Many thanks in advance.
Bryan