Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.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
Javascript 如何在jQuery中创建散列电子邮件?_Javascript_Jquery_Email_Hash - Fatal编程技术网

Javascript 如何在jQuery中创建散列电子邮件?

Javascript 如何在jQuery中创建散列电子邮件?,javascript,jquery,email,hash,Javascript,Jquery,Email,Hash,我需要在jQuery中散列一封电子邮件,以便与一起使用 因此: 将变成: http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50 我能够从Python/Mako获取电子邮件并将其传递到我的jQuery类中 var gravatar_placeholder = $('#modal-vcard .vcard_profile_pic img').prop('src'); var substr = gravatar_placeho

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

因此:

将变成:

http://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50
我能够从Python/Mako获取电子邮件并将其传递到我的jQuery类中

var gravatar_placeholder = $('#modal-vcard .vcard_profile_pic img').prop('src');
var substr = gravatar_placeholder.split('__gravatar__').join(their_email);
用户的电子邮件是
他们的电子邮件
,我需要在上面的第二行前面的jquery/javascript中散列,这样它就会生成

我在这里找到了,但在我的情况下没能用上


有什么建议吗?您是如何做到这一点的?

有几种哈希算法,我不确定您要使用哪种算法,但MD5是一种非常流行的哈希算法

例如,
someemail@test.com
MD5中散列的是
9CB0CBBCDA88377B1E1D66E8D7F01CBAE


下面是另一个使用加密库的示例

<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script>
var hash = CryptoJS.MD5("name@test.com");
var img = new Image();
img.src = "http://www.gravatar.com/avatar/" + hash;
document.body.appendChild(img);
</script>

var hash=CryptoJS.MD5(“name@test.com");
var img=新图像();
img.src=”http://www.gravatar.com/avatar/“+散列;
文件.正文.附件(img);

在将python发送给jQueryAh之前,最好先用python执行此操作,谢谢!我今天刚学会了散列:)太棒了,这太简单了:)
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script>
var hash = CryptoJS.MD5("name@test.com");
var img = new Image();
img.src = "http://www.gravatar.com/avatar/" + hash;
document.body.appendChild(img);
</script>