Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 9 Jahren
Letzter Beitrag:
vor 8 Jahren, 11 Monaten
Beteiligte Autoren:
DerekT, Fred74, Fabrice Harari

Problem with Uncrypt on WDMobile

Startbeitrag von DerekT am 07.07.2009 16:21

WinDev Mobile 12.0

Hi all

I have SOAP client running on Windows Mobile 5.
Part of the SOAP result is a string encoded as BASE64.
Everything is working fine and in the application I can see, by writing the result to a file, the encoded string, this is identical to the string being transmitted from the SOAP server.
But when I attempt to decode this string using ..........

lsSourceXML = Uncrypt(lsRetPayload,"aaa",cryptNone,encodeBASE64)//Decrypt RetPayload

the string is transformed into a rows of question marks.

If I run the same code on the Mobile (i.e. on my pc) simulator everything works fine.

It seems to me that the Uncrypt is attemtpting to decode what it assumes is a unicode string when in fact it is a Base64 ansi string - just a WAG on my part.:confused:

Is there an alternative way of transferring encrypyted strings between WD and WDM using SOAP?




Hi Dereck...

did you try to use unicodetoansi before or after the uncrypt?

Best regards

von Fabrice Harari - am 07.07.2009 17:54
Fabrice, hi

Yes I did, one of many, many variations

gpWriteLog(TimeToString(TimeSys(),"HH:MM:SS") + " Task Received")
//Payload before Uncrypt
gpWriteLog(TimeToString(TimeSys(),"HH:MM:SS ") + Middle(lsRetPayload,1,40))

ansi1 is string = UnicodeToAnsi(lsRetPayload)
gpWriteLog(TimeToString(TimeSys(),"HH:MM:SS ") + Middle(ansi1,1,40))

lsSourceXML = Uncrypt(lsRetPayload,"aaa",cryptNone,encodeBASE64)//Decrypt RetPayload
//Payload after Uncrypt
gpWriteLog(TimeToString(TimeSys(),"HH:MM:SS ") + Middle(lsSourceXML,1,40))
In this case the variable Ansi1 shows
(the missing character is a diamond) as does lsSourcsXML after the Decrypt.

I also tried AnsiToUnicode which produced the runtime error

UnicodeToString function called.
Error caused by 1 parameter.
Unable to convert element from UNICODE string type to string type.



von DerekT - am 07.07.2009 22:44

Re: Problem with Uncrypt on WDMobile - Workaround


I have received from PCS Tech Support the 'This problem has been submitted to our developers. It might require a fix or an upgrade.' message.

I assume therefore that this is a bug in WDMobile.

The workaround was to decode the Base64 on the SOAP server and then encrypt it using CryptFast+cryptAnsi before sending to the mobile device.

Bit of a fiddle but at least it now works.



von DerekT - am 10.07.2009 16:46
hi, i have got the same problem and as i can't wait a fixed, i found a program which decrypt base64. Here the source.

PROCEDURE Base64Decode(pData est chaîne)
BASE64 est chaîne = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
TABLEAU_BASE64BIN est un tableau de 64 chaîne sur 6

Xlc_car est un caractère
Xls_Bin est chaîne
Xle_AscCode est entier sans signe sur 1 octet
Xls_result est chaîne
Xle_taille_pdata est entier
Xle_taille_bin est entier
i est entier

// création du tableau Binaire
POUR i=1 A 64

// extrait le caractère et cherche sa correspondance valeur binaire/hexa
Xle_taille_pdata = Taille(pData)
i = 1
Xlc_car = Milieu(pData, i, 1)
SI Position(BASE64, Xlc_car) 0 ALORS
Xls_Bin += TABLEAU_BASE64BIN[Position(BASE64, Xlc_car)]
SI i > Xle_taille_pdata ALORS SORTIR

// prend la chaine binaire et recode le caractère en décimal
Xle_taille_bin = Taille(Xls_Bin)
i = 1
SI Taille(Milieu(Xls_Bin, i, 8)) < 8 ALORS
Xle_AscCode = BinToDec(Milieu(Xls_Bin, i, 8))
Xls_result += Caract(Xle_AscCode)
i += 8
SI i > Xle_taille_bin ALORS SORTIR

RENVOYER Xls_result

PROCEDURE BinToDec(CodeBin est chaîne)
RENVOYER Val(CodeBin, 2)

PROCEDURE DecToBin(xlpar_binaire est entier)
XL_reste est un booléen
Xl_resultat est chaîne

TANTQUE xlpar_binaire 0
XL_reste = modulo(xlpar_binaire,2)
Xl_resultat = XL_reste + Xl_resultat
// renvoie uniquement partie entière
xlpar_binaire = xlpar_binaire / 2
Xl_resultat = Répète("0",6-Taille(Xl_resultat))+Xl_resultat

RENVOYER Xl_resultat


von Fred74 - am 28.08.2009 10:59
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.