如何在jQuery中创建散列电子邮件? [英] How to create a hashed email in jQuery?

查看:95
本文介绍了如何在jQuery中创建散列电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在jQuery中散列电子邮件,以便与 Gravatar 一起使用

I'm needing to hash an email in jQuery for use with Gravatar.

所以:

http://www.gravatar.com/avatar/user@email.com

将变成:

http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50

我可以从Python / Mako获取电子邮件,并将其传递到我的jQuery类中。

I'm able to get the email from Python/Mako and pass it on into my jQuery class.

var gravatar_placeholder = $('#modal-vcard .vcard_profile_pic img').prop('src');
var substr = gravatar_placeholder.split('__gravatar__').join(their_email);

用户的电子邮件是 them_email ,我需要在上面的第二行之前的jquery / javascript中进行散列,然后生成 Gravatar

The user's email is their_email and I need to hash in jquery/javascript before the 2nd line above so it will then generate the Gravatar.

我发现这个答案在这里,但不能让它在我的情况下工作。

I found this answer here, but wasn't able to get it to work in my situation.

任何提示?你会如何处理这个?

Any tips? How would you have approached this?

推荐答案

有几种哈希算法,我不知道你想要使用哪一个,但MD5是一个非常受欢迎的哈希算法。

There are several hash algorithms and I am not sure which one you want to use but MD5 is a quite popular hash algorithm.

例如,在MD5中散列的 someemail@test.com 9cb0cbcda88377b1e1d66e8d7f01cbae

For instance, someemail@test.com hashed in MD5 is 9cb0cbcda88377b1e1d66e8d7f01cbae.

https://github.com/blueimp/JavaScript-MD5

这篇关于如何在jQuery中创建散列电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆