[GH-ISSUE #35] feature request: export 64-digit encryption key #24

Closed
opened 2026-03-02 03:59:25 +03:00 by kerem · 6 comments
Owner

Originally created by @privnote42 on GitHub (Sep 3, 2022).
Original GitHub issue: https://github.com/ElDavoo/wa-crypt-tools/issues/35

Originally assigned to: @ElDavoo on GitHub.

Hello,
I have a feature request.
Would it be possible to output / export the 64-digit encryption key so that I can import an E2E encrypted backup?

This is the use case:
I forgot my password for the E2E encrypted backup and did not save the 64-digit encryption key.

I wanted to update my phone to a new LineageOS version, so I backed up Whatsapp and then deleted all partitions.
I also made a backup of the Whatsapp folder in /data/data, so I still have encrypted_backup.key as a file.

The export also works without problems, but unfortunately Whatsapp does not seem to accept this non-encrypted database; at least when I reinstalled Whatsapp, I was not offered a restore with it.

Originally created by @privnote42 on GitHub (Sep 3, 2022). Original GitHub issue: https://github.com/ElDavoo/wa-crypt-tools/issues/35 Originally assigned to: @ElDavoo on GitHub. Hello, I have a feature request. Would it be possible to output / export the 64-digit encryption key so that I can import an E2E encrypted backup? This is the use case: I forgot my password for the E2E encrypted backup and did not save the 64-digit encryption key. I wanted to update my phone to a new LineageOS version, so I backed up Whatsapp and then deleted all partitions. I also made a backup of the Whatsapp folder in /data/data, so I still have encrypted_backup.key as a file. The export also works without problems, but unfortunately Whatsapp does not seem to accept this non-encrypted database; at least when I reinstalled Whatsapp, I was not offered a restore with it.
kerem closed this issue 2026-03-02 03:59:26 +03:00
Author
Owner

@ElDavoo commented on GitHub (Sep 3, 2022):

I don't know if that's going to work, but it's certainly doable. Tomorrow morning I will make it that it will be printed in verbose mode. In the meantime, you can try inserting a print(key) in the program, as the Key object has the print method

<!-- gh-comment-id:1236204360 --> @ElDavoo commented on GitHub (Sep 3, 2022): I don't know if that's going to work, but it's certainly doable. Tomorrow morning I will make it that it will be printed in verbose mode. In the meantime, you can try inserting a print(key) in the program, as the Key object has the print method
Author
Owner

@privnote42 commented on GitHub (Sep 3, 2022):

Hi,
I have already tried to output the key in the load_crypt15 function.
But I only get a byte hex code there, which I can't convert with the decode function either, because i got an error.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 3: invalid start byte

Or is that already all I need?
This would be the output (I have already changed some parts so that my real key is not published here):
b'<k\x1f\xb1_\xc0\x06\xbe\xff\xeb\x1cU\nI\x13\xf9\x9c\xe0I\x16DP\x51N\\x9doJ\xc8R\xfc~'

I would then translate it like this
1FB1C006....C8FC

<!-- gh-comment-id:1236205521 --> @privnote42 commented on GitHub (Sep 3, 2022): Hi, I have already tried to output the key in the load_crypt15 function. But I only get a byte hex code there, which I can't convert with the decode function either, because i got an error. UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 3: invalid start byte Or is that already all I need? This would be the output (I have already changed some parts so that my real key is not published here): b'<k\x1f\xb1_\xc0\x06\xbe\xff\xeb\x1cU\nI\x13\xf9\x9c\xe0I\x16DP\x51N\\\x9doJ\xc8R\xfc~' I would then translate it like this 1FB1C006....C8FC
Author
Owner

@privnote42 commented on GitHub (Sep 3, 2022):

ok, I think I got it now.
Now I just output the key object at the end of the main function.
The hex function was probably the missing piece of the puzzle, now I probably have the right hex code.
The next restore attempt I can only do in 12h, because of the frequent reinstallations today...

I will let you know after my next try is done

<!-- gh-comment-id:1236210165 --> @privnote42 commented on GitHub (Sep 3, 2022): ok, I think I got it now. Now I just output the key object at the end of the main function. The hex function was probably the missing piece of the puzzle, now I probably have the right hex code. The next restore attempt I can only do in 12h, because of the frequent reinstallations today... I will let you know after my next try is done
Author
Owner

@privnote42 commented on GitHub (Sep 4, 2022):

ok, the displayed key was accepted during restore.
Thanks again for your help.

Unfortunately, the restore itself did not restore my chats.
I have now found another way and have overwritten the msgstore.db directly in the folder /data/data/com.whatsapp/databases/ after I did the failed restore (without reinstalling whatsapp).
Before overwriting, I stopped whatsapp to be on the safe side and after restarting, all my chats were there again.

Just a quick note in case anyone has the same problem as me with a non-functioning restore

<!-- gh-comment-id:1236404433 --> @privnote42 commented on GitHub (Sep 4, 2022): ok, the displayed key was accepted during restore. Thanks again for your help. Unfortunately, the restore itself did not restore my chats. I have now found another way and have overwritten the msgstore.db directly in the folder /data/data/com.whatsapp/databases/ after I did the failed restore (without reinstalling whatsapp). Before overwriting, I stopped whatsapp to be on the safe side and after restarting, all my chats were there again. Just a quick note in case anyone has the same problem as me with a non-functioning restore
Author
Owner

@ElDavoo commented on GitHub (Sep 5, 2022):

ok, sorry for not doing it yesterday. Would you mind making a pull request?

<!-- gh-comment-id:1236814816 --> @ElDavoo commented on GitHub (Sep 5, 2022): ok, sorry for not doing it yesterday. Would you mind making a pull request?
Author
Owner

@ElDavoo commented on GitHub (Sep 14, 2022):

you just had to uncomment line 683 lol

<!-- gh-comment-id:1246482943 --> @ElDavoo commented on GitHub (Sep 14, 2022): you just had to uncomment line 683 lol
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/wa-crypt-tools#24
No description provided.