--- José Andrés <[EMAIL PROTECTED]> wrote:

> Hello Joe
> 
> well my code for convert the text in hex is this
> 
>    dim cnt As Integer
>    dim Total As Integer
>    dim strHex As String
> 
>    strHex = ""
> 
>    Total = Len(Texto)
> 
>    for cnt = 1 to Total
> 
>      strHex = strHex + Hex(asc(Mid(texto, cnt, 1)))
> 
>    next
> 
>    return strHex

That explains why you're getting inconsistent results.  The Hex
function will return a single character if the ASCII value is
less than 16.  If you have a binary string with the characters

12 0F B9 09 88

your conversion function will return a string

12FB9988

and your deconversion function will turn that back into

12 FB 99 88

So not only are you one character short, but all the characters
after the "FB" are wrong.

You're better off using EncodeBase64 and DecodeBase64.  Just be
aware: when you call EncodeBase64, there's an optional second
argument for how often to insert carriage returns (every 72
characters by default, I believe).  If you're storing SaveInfo
strings in a database you'll be ok, but in a text file the
embedded carriage returns can truncate your SaveInfo string.  Set
the second argument to zero and you'll be ok.


Mark Nutter

Quick and easy regex creation and debugging!
http://www.bucktailsoftware.com/products/regexplorer/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to