am using QCryptographicHash to hash a pass and save it in an XML file, my problem is when I use QDomDocument to read and update other elements in my xml file the element password changes and I don’t know how.
any help please !!!
here is my xml file with correct data
<?xml version='1.0' encoding='UTF-8'?>
<Folders>
<folder DriveL="" Mounted="false" PassW="!Å?L,-;©Óñn?Ãs?N·¦ø" Path="C:\MyProjects\DiskCrypt\testFolder\TestFolder"/>
when I need to update the drive letter I use QDomDocument to read data and modify it, every thing goes all right. My application encrypt my xml file if the user exit ant decrypt it once it rerun, but after the decryption I get this:
<?xml version='1.0' encoding='UTF-8'?>
<Folders>
<folder DriveL="" Mounted="false" PassW="!??L,-;???n??s?N???" Path="C:\MyProjects\DiskCrypt\testFolder\TestFolder"/>
</Folders>
so PassW should be "!Å?L,-;©Óñn?Ãs?N·¦ø" but after encryption it is "!??L,-;???n??s?N???", I use simple algorithm for encrption and decryption (AES 128).
To avoid text encoding issues and also make your XML file human-readable, you should never put binary data directly into your XML document. Use base64 or hexadecimal encoding instead.
Since
QCryptographicHashgenerates a hash in binary form, you have to call.toHex()on the byte array you got from it. (Base64 would also be OK and even smaller, but hexadecimal encoding of hashes is “the default” way to make them human-readable.)