Sha256: 0a87df76bfe48574ceca563a27a095130e4df4b804d3ddea05b668c1c93a21a6

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

<!DOCTYPE html>
<html>
<!--
Copyright 2012 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.crypt.sha256</title>
<script src="../base.js"></script>
<script>
  goog.require('goog.crypt');
  goog.require('goog.crypt.hashTester');
  goog.require('goog.crypt.Sha256');
  goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<script>

function testBasicOperations() {
  var sha256 = new goog.crypt.Sha256();
  goog.crypt.hashTester.runBasicTests(sha256);
}

function testHashing() {
  // Test vectors from:
  // csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf

  var sha256 = new goog.crypt.Sha256();

  // Empty message.
  sha256.update([]);
  assertElementsEquals(
      goog.crypt.hexToByteArray(
          'e3b0c44298fc1c149afbf4c8996fb924' +
          '27ae41e4649b934ca495991b7852b855'),
      sha256.digest());

  // One block message.
  sha256.reset();
  sha256.update(goog.crypt.stringToByteArray('abc'));
  assertElementsEquals(
      goog.crypt.hexToByteArray(
          'ba7816bf8f01cfea414140de5dae2223' +
          'b00361a396177a9cb410ff61f20015ad'),
      sha256.digest());

  // Multi-block message.
  sha256.reset();
  sha256.update(
      goog.crypt.stringToByteArray(
          'abcdbcdecdefdefgefghfghighij' +
          'hijkijkljklmklmnlmnomnopnopq'));
  assertElementsEquals(
      goog.crypt.hexToByteArray(
          '248d6a61d20638b8e5c026930c3e6039' +
          'a33ce45964ff2167f6ecedd419db06c1'),
      sha256.digest());
}

</script>
</body>
</html>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
k4compiler-0.0.1 third_party/closure-library/closure/goog/crypt/sha256_test.html