|
[WM20/W20] UncryptStandard/CryptStandard |
Iniciado por ARV, mar., 21 2018 3:04 PM - 27 respostas |
| |
| | | |
|
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 21 2018 - 3:04 PM |
Hello
I have a problem with the UncryptStandard and CryptStandard, it works on Android Windev Mobile 20 but when I save the buffer on a table on my server and I want to Uncrypt that buffer on a windev 20 it doesn't work at all, the error says that have a problem with the last part of the uncrypt.
heres my code
A is buffer BufKey is buffer
BufKey = HashString(HA_MD5_128,"Password") A = CryptStandard("Data",bufKey,cryptAES128) TableServer.Test = A HAdd(Tableserver)
bufKey is buffer = HashString(HA_MD5_128,"Password") B is buffer
B = UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,cryptAES128)
IF B<>"" THEN Info(B) ELSE Info(ErrorInfo()) END
Someone have the same problem or is it just me? best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 105 mensagems |
|
Publicado em março, 21 2018 - 3:32 PM |
I ran into this exact same thing except in WD22 and WM22. Check your Hash String values. Make sure they're calculating to exactly the same values in the two different programs. I had trouble with that and had to test it by manually inserting a hex value to the hash buffer variable using HexaToBuffer() |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 21 2018 - 4:14 PM |
Hi Jose
what is the type of tableserver.test? Is it a binary memo? If not, and it's a string, you are going to loose some information and you will have to do a buffertohexa before saving it that way.
best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/21/2018 à 9:04 AM, Jose a écrit :
Hello I have a problem with the UncryptStandard and CryptStandard, it works on Android Windev Mobile 20 but when I save the buffer on a table on my server and I want to Uncrypt that buffer on a windev 20 it doesn't work at all, the error says that have a problem with the last part of the uncrypt. heres my code A is buffer BufKey is buffer
BufKey = HashString(HA_MD5_128,"Password") A = CryptStandard("Data",bufKey,cryptAES128) TableServer.Test = A Hadd(Tableserver)
bufKey is buffer = HashString(HA_MD5_128,"Password") B is buffer
B = UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,cryptAES128)
if B<>"" then info(B) else info(Errorinfo()) end
Someone have the same problem or is it just me? best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 21 2018 - 8:34 PM |
Hello
Robert wrote:
I ran into this exact same thing except in WD22 and WM22. Check your Hash String values. Make sure they're calculating to exactly the same values in the two different programs. I had trouble with that and had to test it by manually inserting a hex value to the hash buffer variable using HexaToBuffer()
I tried with HexaToBuffer and I remember that it work I think, I need to do a test again, I will crypt on android and uncrypt on PC and biceversa The thing is that I want to save on my tables the buffer not a Hexa
Fabrice Harari wrote:
Hi Jose what is the type of tableserver.test? Is it a binary memo? If not, and it's a string, you are going to loose some information and you will have to do a buffertohexa before saving it that way. best regards -- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM. More information on http://www.fabriceharari.comLe 3/21/2018 à 9:04 AM, Jose a écrit : Hello I have a problem with the UncryptStandard and CryptStandard, it works on Android Windev Mobile 20 but when I save the buffer on a table on my server and I want to Uncrypt that buffer on a windev 20 it doesn't work at all, the error says that have a problem with the last part of the uncrypt. heres my code //On Android Windev Mobile 20 A is buffer BufKey is buffer BufKey = HashString(HA_MD5_128,"Password") A = CryptStandard("Data",bufKey,cryptAES128) TableServer.Test = A Hadd(Tableserver) //On Windev 20 bufKey is buffer = HashString(HA_MD5_128,"Password") B is buffer B = UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,cryptAES128) if B<>"" then info( else info(Errorinfo()) end Someone have the same problem or is it just me? best regards.
Yes it is a Binary String but when I Crypt on Android the PC doesn't Uncrypt but when I come back on Android it's totally fine. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 21 2018 - 8:47 PM |
Fabrice Harari wrote:
Hi Jose what is the type of tableserver.test? Is it a binary memo? If not, and it's a string, you are going to loose some information and you will have to do a buffertohexa before saving it that way. best regards -- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM. More information on http://www.fabriceharari.comLe 3/21/2018 à 9:04 AM, Jose a écrit : Hello I have a problem with the UncryptStandard and CryptStandard, it works on Android Windev Mobile 20 but when I save the buffer on a table on my server and I want to Uncrypt that buffer on a windev 20 it doesn't work at all, the error says that have a problem with the last part of the uncrypt. heres my code //On Android Windev Mobile 20 A is buffer BufKey is buffer BufKey = HashString(HA_MD5_128,"Password") A = CryptStandard("Data",bufKey,cryptAES128) TableServer.Test = A Hadd(Tableserver) //On Windev 20 bufKey is buffer = HashString(HA_MD5_128,"Password") B is buffer B = UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,cryptAES128) if B<>"" then info( else info(Errorinfo()) end Someone have the same problem or is it just me? best regards.
Hi Fabrice
Wait Do you mean to put a Other binary memo or something like that?
because I put on my table to be a binary String, could you think is that the problem? |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 21 2018 - 9:30 PM |
Hi Jose,
AFAIk, there is no such thing as a binary string. Binaries are by definition the things that are not strings...
So I'm not sure what type of variable you are using, but if you want to store a buffer, it HAS to be a binary memo or you are going to loose information.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/21/2018 à 2:47 PM, Jose a écrit :
Fabrice Harari wrote: Hi Jose what is the type of tableserver.test? Is it a binary memo? If not, and it's a string, you are going to loose some information and you will have to do a buffertohexa before saving it that way. best regards -- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM. More information on http://www.fabriceharari.comLe 3/21/2018 à 9:04 AM, Jose a écrit : Hello I have a problem with the UncryptStandard and CryptStandard, it works on Android Windev Mobile 20 but when I save the buffer on a table on my server and I want to Uncrypt that buffer on a windev 20 it doesn't work at all, the error says that have a problem with the last part of the uncrypt. heres my code //On Android Windev Mobile 20 A is buffer BufKey is buffer BufKey = HashString(HA_MD5_128,"Password") A = CryptStandard("Data",bufKey,cryptAES128) TableServer.Test = A Hadd(Tableserver) //On Windev 20 bufKey is buffer = HashString(HA_MD5_128,"Password") B is buffer B = UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,cryptAES128) if B<>"" then info( else info(Errorinfo()) end Someone have the same problem or is it just me? best regards. Hi Fabrice Wait Do you mean to put a Other binary memo or something like that? because I put on my table to be a binary String, could you think is that the problem? |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 21 2018 - 9:46 PM |
I tried changing the type of my table and it still doesn't work I put Image (binary memo), Other Binary memo and binary String and it doesn't work at all.
Any ideas with Windev mobile 20? also I will try to use BufferToHexa and I will tell if it work |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 22 2018 - 1:21 PM |
Another potential problem is that line :
UncryptStandard(Table_Window[Table_Window].Col_A,bufkey,c
it seems that you are storing the encrypted string in a table control colum before uncrypting it...
However, the encrypted string is a BINARY BUFFER, so there is no type of column that can contain it without loosing some data...
Of course, if you do a buffertohexa or encrypt in base64, the result is a string that you CAN store in table...
So you will have to rethink that part too...
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/21/2018 à 3:46 PM, Jose a écrit :
I tried changing the type of my table and it still doesn't work I put Image (binary memo), Other Binary memo and binary String and it doesn't work at all.
Any ideas with Windev mobile 20? also I will try to use BufferToHexa and I will tell if it work |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 2:15 PM |
Hi Fabrice
Yeah I think that too, so I use a HReadFirst on the table I have on my DB, however I don't have any good results it's still doesn't work, the only way possible to uncrypt it's to convert to Hexa and then Uncrypt, I haven't the chance to test that, when I do I will post if that way work. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 2:24 PM |
Hi Fabrice
When I was trying to tell you about Other Binarys and that stuff I was talking about sub-types like this
And this is my type on DB
Best regards. |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 22 2018 - 2:50 PM |
all of these are binary memos, so no problem there...
What is you latest code ?
Le 3/22/2018 à 8:24 AM, Jose a écrit :
Hi Fabrice When I was trying to tell you about Other Binarys and that stuff I was talking about sub-types like this
And this is my type on DB
Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 3:11 PM |
Hello
I have tested the BufferToHexa() yes it work almost, it works perfectly on Android only but if I want to uncrypt on PC it's doesn't work at all, but if I uncrypt on Android it work perfectly, the only way to work on PC if I convert the password hashstring before using the function of course and the message into StringToUTF8() but if I want to uncrypt on Android it doesn't work at all it only show me some weird strings like kanjis or letters in chinese, I think it's because android doesn't support UTF8, I guess...
So in the end I have no other options, any ideas my fellows developers?
Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 3:34 PM |
Hi Fabrice
Returning to my last code, without useing HexaTobuffer its like this
bufKEY is Buffer = HashString(HA_MD5_128,"Password") bufEncrypt is Buffer = CryptStandard(EDT_Text,bufKEY,cryptAES128)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
UnCrypt on Android
bufKEY is Buffer = HashString(HA_MD5_128,"Password") HReadFirst(TableDB,ID) EDT_Uncrypt = UncryptStandard(TableDB.Pa,BufKEY,cryptAES128)
with this work perfectly on Android now this is PC
Uncrypt PC
HReadFirst(TableDB,ID) bufkey is Buffer= HashString(HA_MD5_128,"Password") bufSResult2 is Buffer = UncryptStandard(TablaErrores.Pa,BufKey,cryptAES128) EDT_Uncrypt= bufSResult2
IF bufSResult2 = "" THEN Info(ErrorInfo(errFullDetails)) END
This is the error on PC
On Android work pertty good.
PD: Remember that I use binary string on Sub-type on my table on DB
thanks for all the help Fabrice Best Regards!Mensagem modificada, março, 22 2018 - 3:38 PM |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 22 2018 - 3:53 PM |
Hi Jose
of course, you have to take into account the fact that strings are by default unicode on android and ansi in windows...
So each and every string should be explicitely declared (is ansi stirng OR is unicode string) on BOTH SIDES THE SAME WAY for anything to be able to function.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/22/2018 à 9:11 AM, Jose a écrit :
Hello
I have tested the BufferToHexa() yes it work almost, it works perfectly on Android only but if I want to uncrypt on PC it's doesn't work at all, but if I uncrypt on Android it work perfectly, the only way to work on PC if I convert the password hashstring before using the function of course and the message into StringToUTF8() but if I want to uncrypt on Android it doesn't work at all it only show me some weird strings like kanjis or letters in chinese, I think it's because android doesn't support UTF8, I guess...
So in the end I have no other options, any ideas my fellows developers?
Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 105 mensagems |
|
Publicado em março, 22 2018 - 4:02 PM |
I may not have explained what I meant very well. When I was working on doing this same thing, I kept running into decryption issues like this. What it ended up being was that the code for HashString(HA_MD5_128,"Password") was generating different hash values on the android device vs on the PC.
So the decryption was failing because the encryption keys were different.
I ended up using bufHash = HexaToBuffer(sHexVal) where I temporarily hard coded sHexVal to a hex value consisting of 16 pairs.
Jose wrote:
Hello
Robert wrote: I ran into this exact same thing except in WD22 and WM22. Check your Hash String values. Make sure they're calculating to exactly the same values in the two different programs. I had trouble with that and had to test it by manually inserting a hex value to the hash buffer variable using HexaToBuffer()
I tried with HexaToBuffer and I remember that it work I think, I need to do a test again, I will crypt on android and uncrypt on PC and biceversa The thing is that I want to save on my tables the buffer not a Hexa
|
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 4:54 PM |
Hi everyone
Ok I get the idea Fabrice but it's like Robert said it lose information heres my code.
pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) sMessa is UNICODE string = EDT_Text bufEncrypt is Buffer = CryptStandard(sMessa,bufKEY,cryptAES128)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
when I use my code on PC like this
HReadFirst(TableDB,ID) pass is UNICODE string = "Password" bufkey is Buffer= HashString(HA_MD5_128,pass) bufSResult2 is Buffer = UncryptStandard(TablaErrores.Pa,BufKey,cryptAES128) EDT_Uncrypt= bufSResult2
IF bufSResult2 = "" THEN Info(ErrorInfo(errFullDetails)) END
this time it's uncrypt but only the first letter.
Now Robert I guess I get it...
Do you mean create the password with a hex but... how? what function Do I use? Do you mean if I create a buffer of 16 pairs with the "Password" and then share the same buffer on my table or generated it again on code?
Thanks for all the help
Best regards. |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 22 2018 - 6:13 PM |
As I was saying, your code is incorrect, or at least imprecise...
What is the type of EDT_Text? Ansi ? UNicode ? What is the type of tablaerrores.pa? Ansi ? Unicode ?
DECLARE TYPED VARIABLES (ansi or unicode) AND USE THEM, not things that will be ansi on one side and unicode on the other
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/22/2018 à 10:54 AM, Jose a écrit :
Hi everyone Ok I get the idea Fabrice but it's like Robert said it lose information heres my code. pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) sMessa is UNICODE string = EDT_Text bufEncrypt is Buffer = CryptStandard(sMessa,bufKEY,cryptAES128)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
when I use my code on PC like this HReadFirst(TableDB,ID) pass is UNICODE string = "Password" bufkey is Buffer= HashString(HA_MD5_128,pass) bufSResult2 is Buffer = UncryptStandard(TablaErrores.Pa,BufKey,cryptAES128) EDT_Uncrypt= bufSResult2
IF bufSResult2 = "" THEN Info(ErrorInfo(errFullDetails)) END
this time it's uncrypt but only the first letter. Now Robert I guess I get it... Do you mean create the password with a hex but... how? what function Do I use? Do you mean if I create a buffer of 16 pairs with the "Password" and then share the same buffer on my table or generated it again on code? Thanks for all the help Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 6:59 PM |
Hi Robert and Fabrice
Can you post your code of how do you resolve this issue in Windev mobile 20? maybe like that I can have an idea.
Also Fabrice what do you think is the problem if I declared my password in a String UNICODE for both sides.
Best regards. |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 22 2018 - 9:12 PM |
UncryptStandard(TablaErrores.Pa
tablaerrores.pa is NOT declared as a unicode string
Le 3/22/2018 à 12:59 PM, Jose a écrit :
Hi Robert and Fabrice
Can you post your code of how do you resolve this issue in Windev mobile 20? maybe like that I can have an idea.
Also Fabrice what do you think is the problem if I declared my password in a String UNICODE for both sides.
Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 9:26 PM |
Hi
This Time I use the Ansi String but I have the same error I show before.
---
Robert wrote:
I may not have explained what I meant very well. When I was working on doing this same thing, I kept running into decryption issues like this. What it ended up being was that the code for HashString(HA_MD5_128,"Password") was generating different hash values on the android device vs on the PC.
So the decryption was failing because the encryption keys were different.
I ended up using bufHash = HexaToBuffer(sHexVal) where I temporarily hard coded sHexVal to a hex value consisting of 16 pairs.
Jose wrote: Hello
Robert wrote: I ran into this exact same thing except in WD22 and WM22. Check your Hash String values. Make sure they're calculating to exactly the same values in the two different programs. I had trouble with that and had to test it by manually inserting a hex value to the hash buffer variable using HexaToBuffer()
I tried with HexaToBuffer and I remember that it work I think, I need to do a test again, I will crypt on android and uncrypt on PC and biceversa The thing is that I want to save on my tables the buffer not a Hexa
Hi Robert
I'm still figured out How Do you resolve that issue, I know that the password you save it on a Hexa and then you convert it with the function HexaToBuffer to use it on the UncryptStandard but Could you show me that part of the password with the Hexa like how do you convert it or what I need to use I can't get the solution at all.
The only think I can get to solve this is to buy Windev Mobile 22 and Windev 22 but that's totally absurd...
Best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 105 mensagems |
|
Publicado em março, 22 2018 - 9:42 PM |
Just run this on both devices to make sure the hex code is coming out the same. If it's not, then there's a problem with your variables.
bufKey is Buffer = HashString(HA_MD5_128,pass) sKey is string = BufferToHexa(bufKey) Info(sKey)
You might also try chaning your CryptStandard() functions. I have mine working like this.
bufEncrypt = CryptStandard(bufDataAsBuffer,bufHash,cryptAES128,cryptCBC,cryptPaddingPKCS) Mensagem modificada, março, 22 2018 - 9:44 PM |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 22 2018 - 10:55 PM |
Hi Robert
Thanks for your reply, I test it and I have no errors with my variables look:
heres my code on Android Using String:
bufKey is buffer = HashString(HA_MD5_128,"Password") sKey is string = BufferToHexa(bufKey) Info(sKey)
it get's me this:
This is my code on PC using String:
bufKey is buffer = HashString(HA_MD5_128,"Password") sKey is string = BufferToHexa(bufKey) Info(sKey)
This is what I get:
Yep this is different but then I gonna test it with Unicode String like this
Code for Android:
sPass is UNICODE string = "Password"
bufKey is Buffer = HashString(HA_MD5_128,sPass) sKey is string = BufferToHexa(bufKey) Info(sKey)
This is what it print:
Code for PC:
sPass is UNICODE string = "Password" bufKey is Buffer = HashString(HA_MD5_128,sPass) sKey is string = BufferToHexa(bufKey) Info(sKey)
This is what it print:
So in the end the HashString with Unicode String works perfectly because are the same now the bad part is the next one, when I Search my bufkey on my table on the DB and I use my PC's bufkey that it's equal with the Android's bufkey it doesn't work even I change my parameters in the CryptStandard, here look I will share my code:
Android Code:
pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) bufMensaje is Buffer = EDT_Texto bufEncriptado is Buffer = CryptStandard(bufMensaje,bufKEY,cryptAES128,cryptCBC,cryptPaddingPKCS)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
pass is UNICODE string = "Password" bufKEY2 is Buffer = HashString(HA_MD5_128,pass) HReadFirst(TablaErrores,ID) bufUncrypt is Buffer = UncryptStandard(TablaErrores.Pa,bufKEY2,cryptAES128) Info(bufUncrypt)
my message To Encrypt is this follow:
And this is what I get when I use UncryptStandard on Android:
Heres my code on PC:
spass is UNICODE string = "Panama2016" bufKey is Buffer = HashString(HA_MD5_128,spass)
HReadFirst(TablaErrores,ID)
Info(UncryptStandard(TablaErrores.Pa,BufKey,cryptAES128,cryptCBC,cryptPaddingPKCS))
And this is what i get:
It just give me the first letter... so... is this the end? I can't think anything else, Do you have any idea of what it's happening?
Best Regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 23 2018 - 2:26 PM |
Fabrice Harari wrote:
UncryptStandard(TablaErrores.Pa
tablaerrores.pa is NOT declared as a unicode string
Le 3/22/2018 à 12:59 PM, Jose a écrit : Hi Robert and Fabrice
Can you post your code of how do you resolve this issue in Windev mobile 20? maybe like that I can have an idea.
Also Fabrice what do you think is the problem if I declared my password in a String UNICODE for both sides.
Best regards.
Hi Fabrice
ok I get it, but theres where my buffer it's save so is it not a binary?, because I save it like one because of the buffer. I think I see it, I will save my EDT_Text on a variable as a Unicode String let me try
also this is the type of my EDT_Text:
PD: TablaErrores is a bad call because its TableDB sorry my bad |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 23 2018 - 2:39 PM |
Hi Fabrice
I change a little my code so this is how it ends on android:
pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) Messa is UNICODE string = EDT_Text bufMessage is Buffer = Messa bufEncypt is Buffer = CryptStandard(bufMessage ,bufKEY,cryptAES128,cryptCBC,cryptPaddingPKCS)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
I don't change code on PC it's the same like this:
spass is UNICODE string = "Password" bufKey is Buffer = HashString(HA_MD5_128,spass)
HReadFirst(TableDB,ID)
Info(UncryptStandard(TableDB.Pa,BufKey,cryptAES128,cryptCBC,cryptPaddingPKCS))
like always it work on Android but in PC it still the first letter.
I only belive that the problem like Fabrice says it's the Edit or the Table on the DB for now on I don't use a table on Window to show the info of my table on DB.
any ideas Fabrice?
best regards. |
| |
| |
| | | |
|
| | |
| |
Publicado em março, 23 2018 - 3:28 PM |
Hi Jose,
on the pc, do this:
usMyUnicodeString is unicode String usMyUNicodeString = UncryptStandard(TableDB.Pa,BufKey,cryptAES128,cryptCBC,cryptPaddingPKCS)
Then check the content of the string in the debugger, or display it in a field that has been marked as unicode...
As a general rule, when you see only the first letter of a string, it's often because the string is in unicode, but your environment is in ansi...
As each letter of regular roman language in unicode is made of Value+BinaryZEro, and as the binary zero is the end of stirng character in ANSI, you will SEE only the first letter if you do not take appropriate precautions.
Best regards
-- Fabrice Harari International WinDev, WebDev and WinDev mobile Consulting
Free Video Courses, free WXShowroom.com, open source WXReplication, open source WXEDM.
More information on http://www.fabriceharari.com
Le 3/23/2018 à 8:39 AM, Jose a écrit :
Hi Fabrice I change a little my code so this is how it ends on android: pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) Messa is UNICODE string = EDT_Text bufMessage is Buffer = Messa bufEncypt is Buffer = CryptStandard(bufMessage ,bufKEY,cryptAES128,cryptCBC,cryptPaddingPKCS)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done") I don't change code on PC it's the same like this: spass is UNICODE string = "Password" bufKey is Buffer = HashString(HA_MD5_128,spass)
HReadFirst(TableDB,ID)
Info(UncryptStandard(TableDB.Pa,BufKey,cryptAES128,cryptCBC,cryptPaddingPKCS)) like always it work on Android but in PC it still the first letter. I only belive that the problem like Fabrice says it's the Edit or the Table on the DB for now on I don't use a table on Window to show the info of my table on DB. any ideas Fabrice? best regards. |
| |
| |
| | | |
|
| | |
| |
Membro registado 498 mensagems Popularité : +8 (8 votes) |
|
Publicado em março, 23 2018 - 10:44 PM |
Hi Fabrice
Good news! it works!! finally!!!! So ok I get it I was Uncrypting an Unicode String but the pc are on Ansi so that's why it doesn't work the first time so yeah heres my code for someone that has the same issue
Code on Windev mobile 20 Android
How to use Cryptstandard:
pass is UNICODE string = "Password" bufKEY is Buffer = HashString(HA_MD5_128,pass) bufEncrypt is Buffer = CryptStandard(EDT_Text,bufKEY,cryptAES128,cryptCBC,cryptPaddingPKCS)
TableDB.Pa = bufEncrypt HAdd(TableDB) Info("Done")
How to use UncryptStandard:
sPass2 is UNICODE string = "Password" bufKEY2 is Buffer = HashString(HA_MD5_128,sPass2) HReadFirst(TableDB,ID) resp is UNICODE string = UncryptStandard(TableDB.Pa,bufKEY2,cryptAES128) Info(resp)
Code on Windev 20 for Windows
How to use UncryptStandart on PC:
spass is UNICODE string = "Password" bufKey is Buffer = HashString(HA_MD5_128,spass)
HReadFirst(TableDB,ID)
resp is UNICODE string = UncryptStandard(TableDB.Pa,BufKey,cryptAES128)
Info(resp)
This is how it work for me but there's something important, on the data base you need to put a really huge Size because the CryptStandard consume a lot of space so keep in mind that por me I put something absurd just to test here take a look.
Thanks a lot Fabrice Harari you are a pro!
best regards my fellows developers!! |
| |
| |
| | | |
|
| | |
| |
Publicado em dezembro, 21 2019 - 2:59 AM |
Para encriptar en móvil (IOS y Android) y desencriptar en WebDev funciona codificando en UTF-8 las cadenas que se van a cifrar.
Aquí dejo el ejemplo de como funciona:
método de cifrado en Windev Mobile:
Procedure Encriptar(CadenaACifrar) Password is Buffer = StringToUTF8("AbCdEf123456Gh") BuffHash is Buffer = HashString(HA_MD5_128, Password) Resp is Buffer = EncryptStandard(Cadena, BuffHash, cryptAES128, cryptCBC, cryptPaddingPKCS) RESULT Resp
Llamado del metodo cifrar en Windev Mobile:
Codigo is Buffer = Encriptar(StringToUTF8(EDT_Codigo))
Llamado del WebService desde Windev Mobile:
Resp is string = ValidarCodigo(Codigo)
Ahora veamos como funciona el método desencriptar en el Web Service con WebDev:
Procedure ValidarCodigo(VarCodigo is Buffer) RESULT Desencriptar(VarCodigo)
Procedure PRIVATE Desencriptar(Cadena) Password is Buffer = StringToUTF8("AbCdEf123456Gh") BuffHash is Buffer = HashString(HA_MD5_128, Password) RespDesc is Buffer = DecryptStandard(Cadena, BuffHash, cryptAES128, cryptCBC, cryptPaddingPKCS) IF RespDesc = "" THEN RESULT ErrorInfo(errFullDetails) ELSE RESULT RespDesc END |
| |
| |
| | | |
|
| | |
| |
Membro registado 6 mensagems |
|
Publicado em maio, 30 2020 - 4:03 PM |
Alexander Celín B. a écrit :
Para encriptar en móvil (IOS y Android) y desencriptar en WebDev funciona codificando en UTF-8 las cadenas que se van a cifrar. Aquí dejo el ejemplo de como funciona: método de cifrado en Windev Mobile: Procedure Encriptar(CadenaACifrar) Password is Buffer = StringToUTF8("AbCdEf123456Gh") BuffHash is Buffer = HashString(HA_MD5_128, Password) Resp is Buffer = EncryptStandard(Cadena, BuffHash, cryptAES128, cryptCBC, cryptPaddingPKCS) RESULT Resp Llamado del metodo cifrar en Windev Mobile: Codigo is Buffer = Encriptar(StringToUTF8(EDT_Codigo)) Llamado del WebService desde Windev Mobile: Resp is string = ValidarCodigo(Codigo) Ahora veamos como funciona el método desencriptar en el Web Service con WebDev: Procedure ValidarCodigo(VarCodigo is Buffer) RESULT Desencriptar(VarCodigo) Procedure PRIVATE Desencriptar(Cadena) Password is Buffer = StringToUTF8("AbCdEf123456Gh") BuffHash is Buffer = HashString(HA_MD5_128, Password) RespDesc is Buffer = DecryptStandard(Cadena, BuffHash, cryptAES128, cryptCBC, cryptPaddingPKCS) IF RespDesc = "" THEN RESULT ErrorInfo(errFullDetails) ELSE RESULT RespDesc END
END
This code works fine between webdev/windev mobile this line is key "Password is Buffer = StringToUTF8("AbCdEf123456Gh") |
| |
| |
| | | |
|
| | | | |
| | |
|