Jump to content

help with encrypt


Go to solution Solved by visnja,

Recommended Posts

okay , so i accidently decrypted 1 file , and saved over my encrypted file,i dont have backup , but i know

password , and algorithm it used , but when i try to encrypt , i get encrypted data thats not the same as before , what am i doing wrong?

Link to comment
Share on other sites

alg was $calg_aes_256 and when i crypt it with the password i used before i get different result,(i check it with my script that used to read it and convert to string,but the result is not the same , i dont get it..)

and yeah visnja is a fruit^^

-update- 

Basicaly when i crypt and decrypt anything  with same pw , i get different result  ... help plz

Edited by visnja
Link to comment
Share on other sites

But darling sweet bitter visnja you should post the code if you want help. If your code is correct then there is no reason not to get the correct result. If you get wrong result then very likely your code is not right. Maybe the input for decription is somehow wrong.

It's impossible to tell without you showing what you did.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

ok i crypt it with this 

#include <crypt.au3>
Local $file = FileOpen(@ScriptDir & "\blabla.lic")
Local $password = ("blabla")
Local $encrypted = FileRead($file)
Local $cryptedbinary = _Crypt_EncryptData($encrypted, $password, $calg_aes_256)
Local $crypted = BinaryToString($cryptedbinary)
MsgBox(0,"",$crypted)
ClipPut($crypted)

then i paste the  data i got into blabla.lic

and decrypt with this

#include <crypt.au3>
Local $file = FileOpen(@ScriptDir & "\blabla.lic")
Local $password = ("blabla")
Local $encrypted = FileRead($file)
Local $decryptedbinary = _crypt_decryptdata($encrypted, $password, $calg_aes_256)
Local $decrypted = BinaryToString($decryptedbinary)
MsgBox(0,"",$decrypted)

and i get weird result on decryption,

and is it possible to crypt with 1 algo and decrypt with other?

Edited by visnja
Link to comment
Share on other sites

If you overwrote a file then I don't know how you can get it back. I would avoid using the same file for plaintext as you use for encryption unless you are really sure everything works as expected. I would also use FileWrite instead of using ClipPut followed by pasting into a document.

Edited by czardas
Link to comment
Share on other sites

I just made blabla file, wrote Test String to it and run both of your snippets like you explained.

And guess what? You are right. At the end I didn't get out what what I put in.

...That's because you did BinaryToString() and then ClipPut(). BinaryToString will convert binary data to string representation, but the problem with your idea is that string is taken to be null-terminated for ClipPut(). That means that when 0x00 binary is found, string will end. In case of encryption algo and the key you used and string I used 0x00 will be at the beginning. So the string will end before it even started.

Long story short - rethink your Clipboard thing strategy and do what czardas told you.

visnja duso.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...