当前位置: 首页>>代码示例>>Python>>正文


Python utils.make_safe_digest函数代码示例

本文整理汇总了Python中zerver.lib.utils.make_safe_digest函数的典型用法代码示例。如果您正苦于以下问题:Python make_safe_digest函数的具体用法?Python make_safe_digest怎么用?Python make_safe_digest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_safe_digest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: user_avatar_hash

def user_avatar_hash(email):
    # Salting the user_key may be overkill, but it prevents us from
    # basically mimicking Gravatar's hashing scheme, which could lead
    # to some abuse scenarios like folks using us as a free Gravatar
    # replacement.
    user_key = email.lower() + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
开发者ID:8trust,项目名称:zulip,代码行数:7,代码来源:avatar.py

示例2: get_stream_cache_key

def get_stream_cache_key(stream_name, realm):
    from zerver.models import Realm
    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return "stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
开发者ID:anteq,项目名称:zulip,代码行数:8,代码来源:cache.py

示例3: gravatar_hash

def gravatar_hash(email: Text) -> Text:
    """Compute the Gravatar hash for an email address."""
    # Non-ASCII characters aren't permitted by the currently active e-mail
    # RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,
    # outlining internationalization of email addresses, and regardless if we
    # typo an address or someone manages to give us a non-ASCII address, let's
    # not error out on it.
    return make_safe_digest(email.lower(), hashlib.md5)
开发者ID:gnprice,项目名称:zulip,代码行数:8,代码来源:avatar_hash.py

示例4: get_stream_cache_key

def get_stream_cache_key(stream_name, realm):
    # type: (text_type, Union[Realm, int]) -> text_type
    from zerver.models import Realm

    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return u"stream_by_realm_and_name:%s:%s" % (realm_id, make_safe_digest(stream_name.strip().lower()))
开发者ID:rlugojr,项目名称:zulip,代码行数:9,代码来源:cache.py

示例5: user_avatar_hash

def user_avatar_hash(uid: Text) -> Text:

    # WARNING: If this method is changed, you may need to do a migration
    # similar to zerver/migrations/0060_move_avatars_to_be_uid_based.py .

    # The salt probably doesn't serve any purpose now.  In the past we
    # used a hash of the email address, not the user ID, and we salted
    # it in order to make the hashing scheme different from Gravatar's.
    user_key = uid + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
开发者ID:gnprice,项目名称:zulip,代码行数:10,代码来源:avatar_hash.py

示例6: user_profile_by_email_cache_key

def user_profile_by_email_cache_key(email):
    # type: (Text) -> Text
    # See the comment in zerver/lib/avatar_hash.py:gravatar_hash for why we
    # are proactively encoding email addresses even though they will
    # with high likelihood be ASCII-only for the foreseeable future.
    return u'user_profile_by_email:%s' % (make_safe_digest(email.strip()),)
开发者ID:TomaszKolek,项目名称:zulip,代码行数:6,代码来源:cache.py

示例7: bot_profile_cache_key

def bot_profile_cache_key(email):
    # type: (Text) -> Text
    return u"bot_profile:%s" % (make_safe_digest(email.strip()))
开发者ID:JamesLinus,项目名称:zulip,代码行数:3,代码来源:cache.py

示例8: user_profile_cache_key

def user_profile_cache_key(email, realm):
    # type: (Text, Realm) -> Text
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm.id,)
开发者ID:JamesLinus,项目名称:zulip,代码行数:3,代码来源:cache.py

示例9: patched_user_avatar_path

def patched_user_avatar_path(user_profile: UserProfile) -> Text:
    email = user_profile.email
    user_key = email.lower() + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
开发者ID:284928489,项目名称:zulip,代码行数:4,代码来源:0032_verify_all_medium_avatar_images.py

示例10: bot_profile_cache_key

def bot_profile_cache_key(email: str) -> str:
    return "bot_profile:%s" % (make_safe_digest(email.strip()))
开发者ID:gregmccoy,项目名称:zulip,代码行数:2,代码来源:cache.py

示例11: user_profile_cache_key_id

def user_profile_cache_key_id(email: str, realm_id: int) -> str:
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,)
开发者ID:gregmccoy,项目名称:zulip,代码行数:2,代码来源:cache.py

示例12: preview_url_cache_key

def preview_url_cache_key(url: str) -> str:
    return "preview_url:%s" % (make_safe_digest(url))
开发者ID:gregmccoy,项目名称:zulip,代码行数:2,代码来源:cache.py

示例13: open_graph_description_cache_key

def open_graph_description_cache_key(content: Any, request: HttpRequest) -> str:
    return 'open_graph_description_path:%s' % (make_safe_digest(request.META['PATH_INFO']))
开发者ID:BakerWang,项目名称:zulip,代码行数:2,代码来源:cache.py

示例14: get_stream_cache_key

def get_stream_cache_key(stream_name, realm_id):
    # type: (Text, int) -> Text
    return u"stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
开发者ID:brockwhittaker,项目名称:zulip,代码行数:4,代码来源:cache.py

示例15: get_huddle_hash

def get_huddle_hash(id_list):
    id_list = sorted(set(id_list))
    hash_key = ",".join(str(x) for x in id_list)
    return make_safe_digest(hash_key)
开发者ID:handelxh,项目名称:zulip,代码行数:4,代码来源:models.py


注:本文中的zerver.lib.utils.make_safe_digest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。