convert asc to text

  • Thread starter Thread starter TJS
  • Start date Start date
T

TJS

small function encodes text to asc values by this loop

' iterate through password text
'-----------------------------------------------
for f=1 to len(pPassword)
pNewPassword=pNewPassword &"|" & ASC( mid(pPassword,f,1) )
next

how can the password be decoded back to readable text ?
when I try this, it returns gibberish

pPassword=split("|132|179|138|42|200","|")
for f= 1 to ubound(pPassword)
pNewPassword= pNewPassword & chr( pPassword(f) )
next
 
TJS

Have a look at the text encoding classes
By instance to create the array when on the used computer is the MSDos 437
codetable (I did not try it with 1252 yet)

Dim arrInput As Byte() = _
System.Text.Encoding.GetEncoding(437).GetBytes(mystring)
Str.Close()

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemtextencodingclasstopic.asp

And better is than to comby that than with crypting by instance this however
there are in my opinion more.

http://msdn.microsoft.com/library/d...pref/html/frlrfsystemsecuritycryptography.asp

I hope this helps?

Cor
 
TJS said:
small function encodes text to asc values by this loop

' iterate through password text
'-----------------------------------------------
for f=1 to len(pPassword)
pNewPassword=pNewPassword &"|" & ASC( mid(pPassword,f,1) )
next

how can the password be decoded back to readable text ?
when I try this, it returns gibberish

pPassword=split("|132|179|138|42|200","|")
for f= 1 to ubound(pPassword)
pNewPassword= pNewPassword & chr( pPassword(f) )
next


\\\
MsgBox("_" & Decode(Encode("Hello World")) & "_")
..
..
..
Private Function Encode(ByVal pPassword As String) As String
Dim s As String, f As Integer
For f = 1 To Len(pPassword)
s = s & "|" & Asc(Mid(pPassword, f, 1))
Next f
Return s
End Function

Private Function Decode(ByVal pPassword As String) As String
Dim s As String, f As Integer
Dim apPassword = Split(pPassword, "|")
For f = 1 To UBound(apPassword)
s = s & Chr(CInt(apPassword(f)))
Next f
Return s
End Function
///

.... works just fine for me.
 
... works just fine for me.
I know and why not, however not really nice in my opinion.
(There is a VB5 sample like this on MSDN)

Cor
 
Cor Ligthert said:
I know and why not, however not really nice in my opinion.

Why is it "not nice"? Maybe the OP needs the routines to be compatible with
another application.
 
"Herfried K. Wagner [MVP]".
Why is it "not nice"? Maybe the OP needs the routines to be compatible
with another application.

Because of the fact that there are complete methods for that in the encode
methods. The last point can be archieved as well.

Cor
 
Cor Ligthert said:
Because of the fact that there are complete methods for that in the encode
methods. The last point can be archieved as well.

Show me the complete method in the .NET Framework that parses text in the
format the OP described and converts a string back to this format...
 
Hefried,
Show me the complete method in the .NET Framework that parses text in the
format the OP described and converts a string back to this format...
I did that already a little bit in my first answer, however because it is
about passwords am I a little bit scared to give sample code for that when
there is no crypting involved. I can give a method, however in fact it is
probably not the right way.

In addition I don't know the codetable the OP is using.

Cor
 
Cor Ligthert said:
I did that already a little bit in my first answer, however because it is
about passwords am I a little bit scared to give sample code for that when
there is no crypting involved. I can give a method, however in fact it is
probably not the right way.

I agree that the algorithm the OP presented is not an encryption algorithm,
it's an encoding.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top