chr() and strconv() do not work consistently 
Author Message
 chr() and strconv() do not work consistently

Hello,

The function chr() and strconv() do not work
consistently. For example :

   s1 = Chr(129)
   k = Asc(s1)
   Debug.Print k 'ouput = 0 ???

This happens on some computers. I guess it is
coused by windows regional and language setting.

How can I solve it ? If the problem is coused by
language setting, could you show me the command
for reading the setting ?

TIA

Bob

*** Sent via Developersdex http://www.*-*-*.com/ ***



Fri, 13 Apr 2012 23:06:19 GMT  
 chr() and strconv() do not work consistently


Quote:
> Hello,

> The function chr() and strconv() do not work
> consistently. For example :

>   s1 = Chr(129)
>   k = Asc(s1)
>   Debug.Print k 'ouput = 0 ???

> This happens on some computers. I guess it is
> coused by windows regional and language setting.

> How can I solve it ?

Don't use strings for binary data, use a byte array; MS broke that in VB4
when they redefined what a String data type is.  What are you trying to
accomplish?


Fri, 13 Apr 2012 23:24:39 GMT  
 chr() and strconv() do not work consistently

Quote:
> The function chr() and strconv() do not work
> consistently. For example :

>   s1 = Chr(129)
>   k = Asc(s1)
>   Debug.Print k 'ouput = 0 ???

There may be "other" forces at work here.

Try it like this:

Quote:
>   s1 = ChrB(129)
>   k = AscB(s1)

Also try this:

Quote:
>   s1 = Chr(129)
>   k = AscB(s1)

DO any of these make any difference? Regards, Saga


Quote:
> Hello,

> The function chr() and strconv() do not work
> consistently. For example :

>   s1 = Chr(129)
>   k = Asc(s1)
>   Debug.Print k 'ouput = 0 ???

> This happens on some computers. I guess it is
> coused by windows regional and language setting.

> How can I solve it ? If the problem is coused by
> language setting, could you show me the command
> for reading the setting ?

> TIA

> Bob

> *** Sent via Developersdex http://www.developersdex.com ***



Sat, 14 Apr 2012 02:00:44 GMT  
 chr() and strconv() do not work consistently

"bob" <nospam> skrev i meddelandet

Quote:
> Hello,

> The function chr() and strconv() do not work
> consistently. For example :

>   s1 = Chr(129)
>   k = Asc(s1)
>   Debug.Print k 'ouput = 0 ???

> This happens on some computers. I guess it is
> coused by windows regional and language setting.

> How can I solve it ? If the problem is coused by
> language setting, could you show me the command
> for reading the setting ?

> TIA

> Bob

> *** Sent via Developersdex http://www.developersdex.com ***

Try also
s1 = Chr$(129)
k = Asc(s1)
Debug.Print k

/Henning



Sat, 14 Apr 2012 04:20:18 GMT  
 chr() and strconv() do not work consistently

Hi Bob Butler,

I have a MySQL table (login table).
The table has 2 varchar columns
(name and password) that hold encrypted data.
The table from my computer can not be read
on another computer. Becouse my encryption
process produces inconsisten data.

The data come from byte array like this :
151 50 193 46 242 171 73 145 12 102 119 183 253 144 32  
Before I store it to the table, I convert it
using StrConv(b(), vbUnicode). The result (ascii list) :
151 50 193 46 242 171 73 145 12 102 119 183 253 144 32  

But StrConv() produces different result on anohter computer :
63 50 65 46 111 -32287 73 -32411 12 102 119 -32443 121 63 32  

I tried to replace StrConv() with chr() but it did not help.
chr(151), chr(242) and chr(145) produced ascii 0.

I am finding strconv() and chr() problem.

Regards,
Bob

*** Sent via Developersdex http://www.developersdex.com ***



Sat, 14 Apr 2012 12:46:51 GMT  
 chr() and strconv() do not work consistently

Quote:

> Hi Bob Butler,

> I have a MySQL table (login table).
> The table has 2 varchar columns
> (name and password) that hold encrypted data.
> The table from my computer can not be read
> on another computer. Becouse my encryption
> process produces inconsisten data.

> The data come from byte array like this :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32
> Before I store it to the table, I convert it
> using StrConv(b(), vbUnicode). The result (ascii list) :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32

> But StrConv() produces different result on anohter computer :
> 63 50 65 46 111 -32287 73 -32411 12 102 119 -32443 121 63 32

> I tried to replace StrConv() with chr() but it did not help.
> chr(151), chr(242) and chr(145) produced ascii 0.

> I am finding strconv() and chr() problem.

Yes, it is codepage conversion from multibyte data to a unicode string.
As said, you can not safely store binary data (character values >127) in
a string and not be subject to codepage conversion.

You may be able to pass the byte array direct to the mysql library, but
then you are at the mercy of it's own codepage conversions.

You could try base64 encoding it before you put it in the table which
then makes it 7bit safe again.

--

i-Catcher Development Team

iCode Systems



Sat, 14 Apr 2012 17:11:55 GMT  
 chr() and strconv() do not work consistently
Perhaps a different approach would help. I guess that you are storing
encrypted password in your login table if this is so then it's not the most
secure method. The preferred way is to create a hash code from the password
and store that, then on login create a hash code of what's entered and
compare the 2.

As a hash code cannot be reversed to derive the original text this is far
more secure. If you are not familiar with hash codes they take a string and
do some arcane maths dependant on the ASCII values and their positions (so
the same letters in a different order produce a different result).

If you are dubious about the claim of impossibility of reversal consider a
CRC which is a sort of hash code, you may have several K of data expressed
as a single long value which plainly cannot be reversed to get the original
back.

Regards

Dave O.


Quote:

> Hi Bob Butler,

> I have a MySQL table (login table).
> The table has 2 varchar columns
> (name and password) that hold encrypted data.
> The table from my computer can not be read
> on another computer. Becouse my encryption
> process produces inconsisten data.

> The data come from byte array like this :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32
> Before I store it to the table, I convert it
> using StrConv(b(), vbUnicode). The result (ascii list) :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32

> But StrConv() produces different result on anohter computer :
> 63 50 65 46 111 -32287 73 -32411 12 102 119 -32443 121 63 32

> I tried to replace StrConv() with chr() but it did not help.
> chr(151), chr(242) and chr(145) produced ascii 0.

> I am finding strconv() and chr() problem.

> Regards,
> Bob

> *** Sent via Developersdex http://www.developersdex.com ***



Sat, 14 Apr 2012 18:57:56 GMT  
 chr() and strconv() do not work consistently


Quote:

> Hi Bob Butler,

> I have a MySQL table (login table).
> The table has 2 varchar columns
> (name and password) that hold encrypted data.
> The table from my computer can not be read
> on another computer. Becouse my encryption
> process produces inconsisten data.

> The data come from byte array like this :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32
> Before I store it to the table, I convert it
> using StrConv(b(), vbUnicode). The result (ascii list) :
> 151 50 193 46 242 171 73 145 12 102 119 183 253 144 32

> But StrConv() produces different result on anohter computer :
> 63 50 65 46 111 -32287 73 -32411 12 102 119 -32443 121 63 32

> I tried to replace StrConv() with chr() but it did not help.
> chr(151), chr(242) and chr(145) produced ascii 0.

Yep, you need to find another way to store the data; Chr and StrConv are
going to corrupt the binary data.  Others have given some ideas; you could
also use Right$("0" & Hex$(b(x),2) to convert each byte to a 2-character hex
string and concatenate them for saving in the database.  Val("&H" &
thecharacter) will convert it back to the original byte value.


Sat, 14 Apr 2012 21:18:56 GMT  
 chr() and strconv() do not work consistently
To add to others suggestions:

Use MD5 to hash the password. Basically you encrypt the password and store
the result, and encrypt user's input and compare both results. If the user
provided the correct input, then both results would match. Here is a VB6
sample:

http://www.frez.co.uk/freecode.htm#md5



Sun, 15 Apr 2012 00:03:38 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. VBA table delete does not work consistently?

2. BookMarks not working consistently

3. EOF() not working consistently

4. AppActivate & Sendkeys not working consistently

5. StrConv(MyString$, vbUnicode) not working correctly on asian windows OS

6. Chr(10) and Chr(13) doesn't work

7. Chr(10) not working?

8. chr() not working for values over 128

9. CHR Function not working in VB 6

10. Proof LostFocus doesn't work consistently

11. onpropertychange event not firing consistently

12. StrConv won't work

 

 
Powered by phpBB® Forum Software