different language windows

D

Darin

I have a program that works perfectly when the computer language is
setup for english, but on a spanish computer it doesn't work properly.
Any idea how I can force this routine to only work in english.

Public Function DecryptText(ByVal in_text As String) As String
Dim strKey As String = "1234"
Dim i As Integer
Dim c As Integer
Dim out_buff As String

For i = 1 To Len(RTrim(in_text))
c = Asc(Mid$(in_text, i, 1))
c -= Asc(Mid(strKey, (i Mod Len(strKey)) + 1, 1))
out_buff &= Chr(c And &HFF)
Next
Return RTrim(out_buff)
End Function

Thanks.

Darin
 
H

Herfried K. Wagner [MVP]

Darin said:
I have a program that works perfectly when the computer language is
setup for english, but on a spanish computer it doesn't work properly.
Any idea how I can force this routine to only work in english.

Public Function DecryptText(ByVal in_text As String) As String
Dim strKey As String = "1234"
Dim i As Integer
Dim c As Integer
Dim out_buff As String

For i = 1 To Len(RTrim(in_text))
c = Asc(Mid$(in_text, i, 1))
c -= Asc(Mid(strKey, (i Mod Len(strKey)) + 1, 1))
out_buff &= Chr(c And &HFF)
Next
Return RTrim(out_buff)
End Function

How do the results differ on the two systems?
 
D

Darin

The characters just differ. It has to do with the unicode setting. I
have seen other english systems where if the language for non-unicode
was something other then english, what is encrypted on a full english
system isn't decrypted. In this case, everything in the regional setting
is set for spanish - mexico.

I just need a method of doing encryption and decryption that is
language-indenpent, but not too easy to crack, and the resulting string
has to have no issues with being stored in an SQL database.

I have looked for some others, but they just store a string of numbers
and I could break it by just looking at it.

Darin
 
H

Herfried K. Wagner [MVP]

Darin said:
The characters just differ. It has to do with the unicode setting. I
have seen other english systems where if the language for non-unicode
was something other then english, what is encrypted on a full english
system isn't decrypted. In this case, everything in the regional setting
is set for spanish - mexico.

Sorry, I missed that you are using 'Asc' and 'Chr' instead of 'AscW' and
'ChrW'. 'Asc'/'Chr' are using the current ANSI codepage which is different
on Spanish and English systems. 'AscW' and 'ChrW' do not have this
"problem".
 
D

Darin

didn't know that. I will have to adjust all current encrypted text and
re-do them so Chr is now ChrW.
Thanks.

Darin
 

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

Top