flat assembler
Message board for the users of flat assembler.
Index
> Windows > CryptProtectData Problem |
Author |
|
DimonSoft 09 Jun 2018, 21:42
What do you expect to see and what makes you think nothing is encrypted? Seeing that you try to output the result by wsprintfW with %s placeholder I feel you don’t really understand what you get as the result of the encryption.
|
|||
09 Jun 2018, 21:42 |
|
jochenvnltn 09 Jun 2018, 22:04
DimonSoft wrote: What do you expect to see and what makes you think nothing is encrypted? Seeing that you try to output the result by wsprintfW with %s placeholder I feel you don’t really understand what you get as the result of the encryption. %s outputs it as a string. You can read about it here --> https://msdn.microsoft.com/en-us/library/windows/desktop/ms647550(v=vs.85).aspx |
|||
09 Jun 2018, 22:04 |
|
Walter 09 Jun 2018, 23:01
This seems to work ok.
Code: include 'win32ax.inc' entry main szData db 'paSS94wordGoesHere!',0 DataSize = $ - szData main: mov [datain.pbData], szData mov [datain.cbData], DataSize invoke CryptProtectData, datain, 0, 0, 0, 0, 0, dataout cinvoke wsprintf,buf,PASS,[dataout.pbData] invoke MessageBox,0,buf,cap,MB_OK invoke CryptUnprotectData, dataout, 0, 0, 0, 0, 0, datain cinvoke wsprintf,buf,PASS,[datain.pbData] invoke MessageBox,0,buf,cap,MB_OK invoke ExitProcess,0 section '.data' data readable writeable struct DATA_BLOB cbData dd ? pbData dd ? ends datain DATA_BLOB dataout DATA_BLOB cap db 'Result',0 PASS db 'Pass: %s',10,13,0 buf db 64 dup (?) section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ Crypt32, 'Crypt32.dll' import Crypt32,\ CryptUnprotectData, 'CryptUnprotectData',\ CryptProtectData,'CryptProtectData' include 'api\kernel32.inc' include 'api\user32.inc' |
|||
09 Jun 2018, 23:01 |
|
revolution 10 Jun 2018, 02:01
I'm not sure that passwords should ever be encrypted unless you are storing them in a password vault. For most other uses they should be hashed with a salt.
|
|||
10 Jun 2018, 02:01 |
|
DimonSoft 10 Jun 2018, 07:06
jochenvnltn wrote:
I do know what %s does. Everyone knows. There’s absolutely no sense in using it with arrays of bytes (which is what you get after encryption). Your code works as expected and encrypts original message. And if you want to talk about reading documentation, you’d better follow this link and then (1) add LocalFree to your code and (2) stop calling GetLastError unless the function returns FALSE. Both are not necessary to get the encrypted string but should be kept in mind if you’re going to transform your code into something larger. |
|||
10 Jun 2018, 07:06 |
|
jochenvnltn 10 Jun 2018, 12:05
Walter wrote: This seems to work ok. Thank you Walter ! You helped me out allot! thx |
|||
10 Jun 2018, 12:05 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.