add memory limit check for scrypt (#3328)

* add memory limit check for scrypt

fixes #3323

* test a pass

* move _MEM_LIMIT to the scrypt module
3 files changed