564
edits
| Line 40: | Line 40: | ||
SHA 256 hashes are handy for storing passwords and generating checksums (among other uses) | SHA 256 hashes are handy for storing passwords and generating checksums (among other uses) | ||
Example code uses the hashing API: '''window. | Example code uses the hashing API: '''window.crypto.hash.*''' | ||
[Constructor(in DOMString algorithm)] | |||
08.interface CryptoHash { | |||
09.void append(in ArrayBuffer data); | |||
10.ArrayBuffer finish(); | |||
11.}; | |||
<pre class="brush:js;toolbar:false;"> | <pre class="brush:js;toolbar:false;"> | ||
window. | var hasher = new window.crypto.hash("RS256"); | ||
var myData = "1234567890abcdefghijklmnopqrstuwxyz"; | |||
}); | var arrBufferView = new Int8Array(myData.length); | ||
for (var i = 0; i < myData.length; i++) { | |||
arrBufferView[i] = myData.charCodeAt(i); | |||
} | |||
hasher.append(arrBufferView); | |||
var hashed = hasher.finish(); | |||
// Another idea: generating a file checksum in conjunction with the FileAPI | // Another idea: generating a file checksum in conjunction with the FileAPI | ||
edits