Home All Groups Group Topic Archive Search About

different language windows

Author
18 Sep 2006 8:49 PM
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

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

Author
18 Sep 2006 9:48 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Darin" <darin_nospam@nospamever> schrieb:
>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?

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
18 Sep 2006 11:03 PM
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

*** Sent via Developersdex http://www.developersdex.com ***
Author
19 Sep 2006 12:06 AM
Herfried K. Wagner [MVP]
"Darin" <darin_nospam@nospamever> schrieb:
> 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".

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
19 Sep 2006 1:05 AM
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

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