JavaScript/HASH:修订间差异
来自康健生活
小 文字替换 -“{{leftrightflex|”替换为“{{Double-columns|” |
|||
| 第20行: | 第20行: | ||
=== 霍纳算法 === | === 霍纳算法 === | ||
实现一: | 实现一: | ||
{{ | {{Double-columns|<syntaxhighlight lang="javascript"> | ||
String.prototype.HASHCode = function(){ | String.prototype.HASHCode = function(){ | ||
let hash = 0; | let hash = 0; | ||
| 第34行: | 第34行: | ||
实现二: | 实现二: | ||
{{ | {{Double-columns|<syntaxhighlight lang="javascript"> | ||
String.prototype.HASHCode = function(){ | String.prototype.HASHCode = function(){ | ||
const MAX_VALUE = 0x7fffffff; | const MAX_VALUE = 0x7fffffff; | ||
| 第49行: | 第49行: | ||
== SHA == | == SHA == | ||
{{ | {{Double-columns|<syntaxhighlight lang="javascript"> | ||
String.prototype.SHACode = async function(){ | String.prototype.SHACode = async function(){ | ||
const msgUint8 = new TextEncoder().encode(this) | const msgUint8 = new TextEncoder().encode(this) | ||