Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在谷歌应用程序引擎(GAE)上使用bcrypt?_Python_Google App Engine_Password Protection_Bcrypt - Fatal编程技术网

Python 如何在谷歌应用程序引擎(GAE)上使用bcrypt?

Python 如何在谷歌应用程序引擎(GAE)上使用bcrypt?,python,google-app-engine,password-protection,bcrypt,Python,Google App Engine,Password Protection,Bcrypt,我发现一个用于python的bcrypt库似乎非常易于使用: 在我的本地机器上安装并测试hello world示例后,一切似乎都很好: >>> import bcrypt >>> password = b"super secret password" >>> # Hash a password for the first time, with a certain number of rounds >>> hashed

我发现一个用于python的bcrypt库似乎非常易于使用:

在我的本地机器上安装并测试hello world示例后,一切似乎都很好:

>>> import bcrypt
>>> password = b"super secret password"
>>> # Hash a password for the first time, with a certain number of rounds
>>> hashed = bcrypt.hashpw(password, bcrypt.gensalt(10))
>>> # Check that a unhashed password matches one that has previously been
>>> #   hashed
>>> if bcrypt.hashpw(password, hashed) == hashed:
...     print("It Matches!")
... else:
...     print("It Does not Match :(")
但是,在我的GAE应用程序中,当我使用
import bcrypt
时,我得到一个错误:

Traceback (most recent call last):
  File "/home/pedro/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/pedro/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/pedro/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject
    obj = __import__(path[0])
  File "/home/pedro/google_appengine/hw4/blog.py", line 8, in <module>
    import bcrypt
ImportError: No module named bcrypt
INFO     2014-05-05 21:17:04,375 module.py:639] default: "GET /blog/signup HTTP/1.1" 500 -
然而,当我在官方页面上查看支持的库时,我找不到任何关于bcrypt的信息


那么,如何在GAE中使用bcrypt库呢?甚至可能吗?

您必须在项目中包含bcrypt(或任何其他非嵌入式库)的源代码。 建议在项目的根目录(app.yaml所在的同一级别)上创建一个libs文件夹,并根据需要放置尽可能多的库源

对于这种情况,最终结果应该是:/libs/bcrypt/

确保在希望代码将此文件夹视为包的任何新文件夹中包含_init__u;.py空白文件。之后,只需从libs.bcrypt import bcrypt导入模块:


编辑:还请注意,您可以在应用程序引擎项目上添加。试试看,它对appengine上托管的项目来说就像一种魅力。

将源代码放在文件夹中是一种方法。Thx,使用py-crypt真的很有帮助!
application: calm-grid-571
version: 1
runtime: python27
api_version: 1
threadsafe: False

handlers:
- url: /static
  static_dir: static

- url: /.*
  script: blog.app

libraries:
- name: jinja2
  version: latest

- name: PIL
  version: latest