Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Remove upper case constants (#47)
Browse files Browse the repository at this point in the history
Remove usage of upper-case constants.

Don't test on stable any more.
  • Loading branch information
lrhn authored May 3, 2018
1 parent d810413 commit 8b9705e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: dart

dart:
- stable
- dev

dart_task:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.3

* Updated SDK version to 2.0.0-dev.17.0

## 2.0.2+1

* Fix SDK constraint.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ objects.

```dart
import 'package:crypto/crypto.dart';
import 'dart:convert'; // for the UTF8.encode method
import 'dart:convert'; // for the utf8.encode method
void main() {
var bytes = UTF8.encode("foobar"); // data being hashed
var bytes = utf8.encode("foobar"); // data being hashed
var digest = sha1.convert(bytes);
Expand All @@ -48,8 +48,8 @@ import 'package:crypto/crypto.dart';
import 'package:crypto/src/digest_sink.dart';
void main() {
var firstChunk = UTF8.encode("foo");
var secondChunk = UTF8.encode("bar");
var firstChunk = utf8.encode("foo");
var secondChunk = utf8.encode("bar");
var ds = new DigestSink();
var s = sha1.startChunkedConversion(ds);
Expand Down Expand Up @@ -81,8 +81,8 @@ import 'package:crypto/crypto.dart';
import 'package:crypto/src/digest_sink.dart';
void main() {
var key = UTF8.encode('p@ssw0rd');
var bytes = UTF8.encode("foobar");
var key = utf8.encode('p@ssw0rd');
var bytes = utf8.encode("foobar");
var hmacSha256 = new Hmac(sha256, key); // HMAC-SHA256
var digest = hmacSha256.convert(bytes);
Expand Down
9 changes: 4 additions & 5 deletions lib/src/hash_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class HashSink implements Sink<List<int>> {
final Sink<Digest> _sink;

/// Whether the hash function operates on big-endian words.
final Endianness _endian;
final Endian _endian;

/// The words in the current chunk.
///
Expand Down Expand Up @@ -47,8 +47,7 @@ abstract class HashSink implements Sink<List<int>> {
///
/// [chunkSizeInWords] represents the size of the input chunks processed by
/// the algorithm, in terms of 32-bit words.
HashSink(this._sink, int chunkSizeInWords,
{Endianness endian: Endianness.BIG_ENDIAN})
HashSink(this._sink, int chunkSizeInWords, {Endian endian: Endian.big})
: _endian = endian,
_currentChunk = new Uint32List(chunkSizeInWords);

Expand Down Expand Up @@ -80,7 +79,7 @@ abstract class HashSink implements Sink<List<int>> {
}

Uint8List _byteDigest() {
if (_endian == Endianness.HOST_ENDIAN) return digest.buffer.asUint8List();
if (_endian == Endian.host) return digest.buffer.asUint8List();

var byteDigest = new Uint8List(digest.lengthInBytes);
var byteData = byteDigest.buffer.asByteData();
Expand Down Expand Up @@ -143,7 +142,7 @@ abstract class HashSink implements Sink<List<int>> {
// manually instead.
var highBits = lengthInBits >> 32;
var lowBits = lengthInBits & mask32;
if (_endian == Endianness.BIG_ENDIAN) {
if (_endian == Endian.big) {
byteData.setUint32(offset, highBits, _endian);
byteData.setUint32(offset + bytesPerWord, lowBits, _endian);
} else {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/md5.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class _MD5Sink extends HashSink {
@override
final digest = new Uint32List(4);

_MD5Sink(Sink<Digest> sink)
: super(sink, 16, endian: Endianness.LITTLE_ENDIAN) {
_MD5Sink(Sink<Digest> sink) : super(sink, 16, endian: Endian.little) {
digest[0] = 0x67452301;
digest[1] = 0xefcdab89;
digest[2] = 0x98badcfe;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: crypto
version: 2.0.2+1
version: 2.0.3
author: Dart Team <[email protected]>
description: Library of cryptographic functions.
homepage: https://www.github.com/dart-lang/crypto
environment:
sdk: '>=1.16.0 <2.0.0'
sdk: '>=2.0.0-dev.17.0 <2.0.0'
dependencies:
collection: '^1.0.0'
convert: '>=1.0.0 <3.0.0'
Expand Down

0 comments on commit 8b9705e

Please sign in to comment.