Avoid calling ByteData.setUint64.
Closes #31
R=kevmoo@google.com
Review URL: https://codereview.chromium.org//1825983002 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d97adc..33621aa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.9.2+1
+
+* Avoid core library methods that don't work on dart2js.
+
## 0.9.2
* `Hash`, `MD5`, `SHA1`, and `SHA256` now implement `Converter`. They convert
diff --git a/lib/src/hash_sink.dart b/lib/src/hash_sink.dart
index a3cef94..f4adcb3 100644
--- a/lib/src/hash_sink.dart
+++ b/lib/src/hash_sink.dart
@@ -128,7 +128,20 @@
// hash.
var offset = _pendingData.length;
_pendingData.addAll(new Uint8List(8));
- _pendingData.buffer.asByteData().setUint64(offset, lengthInBits, _endian);
+ var byteData = _pendingData.buffer.asByteData();
+
+ // We're essentially doing byteData.setUint64(offset, lengthInBits, _endian)
+ // here, but that method isn't supported on dart2js so we implement it
+ // manually instead.
+ var highBits = lengthInBits >> 32;
+ var lowBits = lengthInBits & mask32;
+ if (_endian == Endianness.BIG_ENDIAN) {
+ byteData.setUint32(offset, highBits, _endian);
+ byteData.setUint32(offset + bytesPerWord, lowBits, _endian);
+ } else {
+ byteData.setUint32(offset, lowBits, _endian);
+ byteData.setUint32(offset + bytesPerWord, highBits, _endian);
+ }
}
/// Rounds [val] up to the next multiple of [n], as long as [n] is a power of
diff --git a/pubspec.yaml b/pubspec.yaml
index 16be73c..bcafa71 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: crypto
-version: 0.9.2
+version: 0.9.2+1
author: Dart Team <misc@dartlang.org>
description: Library of cryptographic functions.
homepage: https://www.github.com/dart-lang/crypto
diff --git a/test/utils.dart b/test/utils.dart
index dee342a..1f58e96 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -2,9 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:math' as math;
-import 'dart:io';
-
import 'package:crypto/crypto.dart';
import 'package:test/test.dart';