Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: packages/crypto/example/hash.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/crypto/codereview.settings ('k') | packages/crypto/lib/crypto.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/crypto/example/hash.dart
diff --git a/packages/crypto/example/hash.dart b/packages/crypto/example/hash.dart
new file mode 100644
index 0000000000000000000000000000000000000000..825d132ab5871a7f40c3924351e50d58b55439a3
--- /dev/null
+++ b/packages/crypto/example/hash.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// 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:async';
+import 'dart:io';
+
+import 'package:crypto/crypto.dart';
+
+final _usage = 'Usage: dart hash.dart <md5|sha1|sha256> <input_filename>';
+
+Future main(List<String> args) async {
+ if (args == null || args.length != 2) {
+ print(_usage);
+ exit(1);
+ }
+
+ Hash hasher;
+
+ switch (args[0]) {
+ case 'md5':
+ hasher = md5;
+ break;
+ case 'sha1':
+ hasher = sha1;
+ break;
+ case 'sha256':
+ hasher = sha256;
+ break;
+ default:
+ print(_usage);
+ exit(1);
+ }
+
+ var filename = args[1];
+ var input = new File(filename);
+
+ if (!input.existsSync()) {
+ print('File "$filename" does not exist.');
+ exit(1);
+ }
+
+ var value = await hasher.bind(input.openRead()).first;
+
+ print(value);
+}
« no previous file with comments | « packages/crypto/codereview.settings ('k') | packages/crypto/lib/crypto.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698