Articles in this section

How to convert DIGEST to EDIGEST base64?

Context

Aerospike Backup tool (asbackup) currently stores the DIGEST of a record as a  base64 EDIGEST.
At times it may be necessary to convert from the 20 bytes DIGEST to base64 EDIGEST. 
 

Method

The conversion can be done in either python or bash:
 
python2 -c 'print "<DIGEST>".decode("hex").encode("base64")'
python3 -c 'from base64 import b64encode, b64decode;digest="<DIGEST>";print(b64encode(bytes.fromhex(digest)).decode())'

or
 
echo '<DIGEST>'| xxd -r -p|base64

example:
 
# python2 -c 'print "EC91192D4B7F8CE35D5D78D34BCA65CBAAAAC960".decode("hex").encode("base64")'
7JEZLUt/jONdXXjTS8ply6qqyWA=

#python3 -c 'from base64 import b64encode, b64decode;digest="fEC91192D4B7F8CE35D5D78D34BCA65CBAAAAC960";print(b64encode(bytes.fromhex(digest)).decode())'
7JEZLUt/jONdXXjTS8ply6qqyWA=

# echo 'EC91192D4B7F8CE35D5D78D34BCA65CBAAAAC960'| xxd -r -p|base64
7JEZLUt/jONdXXjTS8ply6qqyWA=

which matches the asbackup EDIGEST:
 
cat test.bk 
Version 3.1
# namespace test
# first-file
+ n test
+ d 7JEZLUt/jONdXXjTS8ply6qqyWA=
+ s demo
+ g 1
+ t 0
+ b 2
- I foo 123
- S bar 3 abc

 

Applies To Earliest Version

Pre 4.9

Applies To Latest Version

Current Version
Was this article helpful?
0 out of 0 found this helpful