PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile 2024 → Encrypt, Decrypt and the "<0>"
Encrypt, Decrypt and the "<0>"
Iniciado por Rafael Pires, jun., 15 2021 11:43 AM - 1 resposta
Publicado em junho, 15 2021 - 11:43 AM
Hello, first of all thank u for your time.

Then, i'm doing a iOS/Android app that comunicate with a webservice created in webdev.

first i make a encrypt in iOS to send information in WS. like this:

LoginData is string = Encrypt( cx_Username + "|" + cx_Password,gsCryptKey, cryptNone, encodeBASE64URL)
LicRequest is string
IF OnTestMode() THEN
LicRequest = StringBuild(LicUrlTest,"100", gsTokenval, LoginData, gsLicenca)
ELSE
LicRequest = StringBuild(LicUrlTest,"100", gsTokenval, LoginData, gsLicenca)

END
IF httpRequest(LicRequest) = True THEN


in the WS i receive the information like this:
GLOBAL

gbufRes is Buffer
gbufSMXL is Buffer = ExtractString(PageParameter(1),2,"Ticket.=")
gsAction is string = PageParameter("Action")
gsFunc is string = PageParameter("Func")
gsValue is string = AnsiToUnicode(PageParameter("Value"))
gsClientID = PageParameter("UserID")


gSNValueJson is JSON =gsValue

gsDecriptval is UNICODE string = AnsiToUnicode(Decrypt(gsValue,gsCryptKey, cryptNone, encodeBASE64URL))

SWITCH Upper(gsAction)
CASE "10"
validacao(gsValue)
CASE "50"
LigarHFCS("localhost","ws", "100Esquecer!!i9", gsClientID)

IF HNbRec(feriados) = 0 THEN
criar_feriados()
END

IF HNbRec(tipo_de_faltas) = 0 THEN
criar_tipos_de_falta()
END
CASE "75"
administrator(gsValue)
CASE "100"
UsernameVal is string = ExtractString(gsDecriptval,1,"|",FromBeginning)
PasswordVal is string = ExtractString(gsDecriptval,2,"|",FromBeginning)
Login(UsernameVal,PasswordVal)


the problem is that i encrypt "Admin" and decrypt in webdev like "A<0>d<0>m<0>i<0>n<0>"

i found this thread: https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/24055-crypt-uncrypt/read.awp

but can't i'm not seeing how to make this in my code...

Thank you! :)
Publicado em junho, 15 2021 - 8:45 PM
you found ONE of the 300 different threads where the same question is answered...

So one more time

Windev by default is unicode (Admin)
Android by default is ansi ("A<0>d<0>m<0>i<0>n<0>")

your problem is twofold

"is string" should be replaced by is ansi string (or is unicode string, but same on both sides)

"MyString" (by example "Ticket.=") should NEVER be used directly in the code. Instead do
asMyString is ansi string = "Ticket.="
then use asMyString in the code

This forces BOTH sides to use the same type of strings, and allows you to crypt the same thing on both sides