Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9175449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:54:54+00:00 2026-06-17T16:54:54+00:00

I am new to MongoDB. Anyway, I am trying to save some data that

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:54:55+00:00Added an answer on June 17, 2026 at 4:54 pm

    Not sure if you still need this (or why you’re converting from binary to base64 to binary), but I hope this helps:

    import base64
    import pymongo
    from pymongo import binary
    # if pymongo version >= 1.9, use the following instead
    # from bson import binary
    
    con = pymongo.Connection()
    b64 = base64.b64encode("ajskldfjaklsdjfklasdjf")
    bi = binary.Binary(b64)
    con.test.test.insert({'foo': bi})
    con.test.test.find_one({'foo': bi})
    

    Output:

    {
        u'_id': ObjectId('50f99b4a9f956a1924000000'),
        u'foo': Binary('YWpza2xkZmpha2xzZGpma2xhc2RqZg==', 0)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to MongoDB and trying out some fundamentals, but this astonished me. I'm
I'm trying to parse a very large chunk of data into a new MongoDB
I have some data in MongoDB that looks like this: { name: Steve, location:
I'm new on mongoDB and the point is, that we new realize an bug
I am making a new application in MongoDB, and I have found that the
I'm new to MongoDB and I've used RDBMS for years. Anyway, let's say I
I'm looking to migrate a table of user data to my shiny new MongoDB
I am new to mongoDB and pymongo, trying to learn how to load and
First to say that I'm new to MongoDb and document oriented db's in general.
I'm attempting to use use the new MongoDB aggregation features to tally some statistics

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.