在最新的浏览器中是否有内建的JavaScript字符串散列函数? [英] is there any builtin javascript string hash function in newest browsers?
问题描述
通过最新的浏览器,我的意思是今天的开发版本太喜欢Opera 12,Chrome 17或Firefox 10.
寻找解决方案我在这里找到了另一个线程的评论: 你知道javascript对象吗?已经是散列表?)。那么这些哈希表是什么?这是否意味着我可以将任何字符串转换为哈希值,但不是像md5或sha1这样的已建立的字符串,但是某些JS会在特定的情况下生成?
基本上我需要做的是:
var txt =Hello world!;
var hash = txt.toSha1();
任何人仍然在寻找这些信息。有一个 WebCrypto API ,它似乎已在2017年初。
要在浏览器中使用它,您可以在 window.crypto.subtle
其中包含加密,摘要等方法。有关可用函数的文档此处 a>。
Everytime a new versions of browsers show up I hear about new stuff being added, like say webGL and other technologies that no one really knows if they catch up.
But I wonder if someone ever thought about such basic stuff in JS like hashing functions (MD5,SHA1 and the like).
By newest browsers I mean today's development versions too like Opera 12, Chrome 17 or Firefox 10.
Looking now for solution I found this comment on another thread here: https://stackoverflow.com/questions/7204097/short-hashing-function-for-javascript (Do you know that javascript objects already are hashtables ?). So what are these 'hashtables' ? Does it mean that I can make any string into a hash, but not an established one like md5 or sha1 but some JS build in specific ?
basically what I need to do is:
var txt="Hello world!";
var hash = txt.toSha1();
For anybody still looking for this information. There is a WebCrypto API which appears to have been finalised at the beginning of 2017.
To use it in a browser, you can find it at window.crypto.subtle
which contains methods for encryption, digests etc. Documentation on the available functions here.
这篇关于在最新的浏览器中是否有内建的JavaScript字符串散列函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!