sha-512.html 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>

<script>
description("Test crypto.subtle.digest.");

jsTestIsAsync = true;

16
Promise.resolve(null).then(function() {
17
    debug("SHA512 of []");
18
    return crypto.subtle.digest('sha-512', new Uint8Array([]));
19
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
20 21
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'");
22 23

    debug("SHA512 of [0x0]")
24
    return crypto.subtle.digest({name: 'sha-512'}, new Uint8Array([0]));
25
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
26 27
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'b8244d028981d693af7b456af8efa4cad63d282e19ff14942c246e50d9351d22704a802a71c3580b6370de4ceb293c324a8423342557d4e5c38438f0e36910ee'");
28 29 30

    debug("SHA512 of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]");
    var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
31
    return crypto.subtle.digest({name: 'sha-512'}, data);
32
}).then(function(result) {
ap@apple.com's avatar
ap@apple.com committed
33 34
    digest = result;
    shouldBe("bytesToHexString(new Uint8Array(digest))", "'8ffaee0cccc162851faf051ae38667eefd423c0164c50055f8ade00afc3705e3cdeb9900004b0e426ca66ab63aa3b99b075273f44fd37c22a3555c6fd1f37ccb'");
35 36 37 38 39 40 41
    finishJSTest();
});
</script>

<script src="../../resources/js-test-post.js"></script>
</body>
</html>