redis-rdb-tools icon indicating copy to clipboard operation
redis-rdb-tools copied to clipboard

how read binary key from file that is exported by -e print ?

Open linux2014linux opened this issue 7 years ago • 3 comments

I exported some result to file by '-e print'. I want to read key in file to get redis content. But I found some binary key, example:

binary_key: \x0A\x0E\x08\x8A\xBC\xE2\xCB\x05\x10\x16\x18\x0E(\x058\x02

I try parse binary_key by decode('hex), but happen some error follow info:

TypeError: Odd-length string

How do I solve the problem?

linux2014linux avatar Dec 18 '17 02:12 linux2014linux

only the non-printable chars are converted to hex. look at escape_ascii_bytes in rdbtools/encodehelpers.py

so yo can that this sequence can be fed directly to python as a literal. print("\x28 - (") ( - (

oranagra avatar Dec 18 '17 06:12 oranagra

I think in python 2 you should use decode('string_escape')

oranagra avatar Dec 18 '17 08:12 oranagra

do this: -e base64

wudanyang6 avatar Nov 28 '20 03:11 wudanyang6