I am new to MongoDB. Anyway, I am trying to save some data that is encrypted and base64 encoded.
data = b64encode(self.iv + AES.new(self.key, self.mode, self.iv).encrypt(self.pad2(self.data)))
self.db.users.insert({'data':data})
self.db.users.find({'data':data})
The insert works fine, but finding data returns 0 results. MongoDB shell outputs this:
db.users.find()
{ "_id" : ObjectId("50f848dc34257b0d5e3d9b29"), "data" : BinData(0,"R1VhaHl3MGpLSStkY0lWU255ZjhneGp2RWk3cEk3MnFRTCsxOTcyOC82WT0=")}
How can I find my document by BinData filetype now? I’ve tried bson.binary.Binary no luck there.
Not sure if you still need this (or why you’re converting from binary to base64 to binary), but I hope this helps:
Output: