checkiz / elixir-mongo

MongoDB driver for Elixir
MIT License
101 stars 31 forks source link

new crypto issue #35

Open razeghi71 opened 7 years ago

razeghi71 commented 7 years ago

Hi,

recently when I try to use elixir-mongo I get following error message:

06:09:01.242 [error] Task #PID<0.842.0> started from Quantum terminating
** (UndefinedFunctionError) function :crypto.rand_bytes/1 is undefined or private. Did you mean one of:

      * rand_seed/0
      * rand_seed/1

    (crypto) :crypto.rand_bytes(4)
    (mongo) lib/mongo_server.ex:294: Mongo.Server.gen_reqid/0
    (mongo) lib/mongo_server.ex:93: Mongo.Server.send/2
    (mongo) lib/mongo_collection.ex:109: Mongo.Collection.update/5

Is there any fix?

razeghi71 commented 7 years ago

After some search, I figured out that rand_bytes function is now deprecated and we should use strong_rand_bytes instead.

dapperAuteur commented 7 years ago

thank you. also impacts Exlixir Phoenix Framework testing

NucProject commented 6 years ago

Yes, the line bold would fix defp genreqid() do **<<tail::24, ::1, head::7>> = :crypto.strong_rand_bytes(4)** <<tail::24, 0::1, head::7>> end

It works now