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

Side by Side Diff: pkg/crypto/lib/crypto.dart

Issue 16410007: Get the api docs generated for the crypto package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/crypto/lib/src/crypto_utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart.crypto; 5 library crypto;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 part 'src/crypto_utils.dart'; 9 part 'src/crypto_utils.dart';
10 part 'src/hash_utils.dart'; 10 part 'src/hash_utils.dart';
11 part 'src/hmac.dart'; 11 part 'src/hmac.dart';
12 part 'src/md5.dart'; 12 part 'src/md5.dart';
13 part 'src/sha1.dart'; 13 part 'src/sha1.dart';
14 part 'src/sha256.dart'; 14 part 'src/sha256.dart';
15 15
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 * 49 *
50 * This is exposed for use by the HMAC class which needs to know the 50 * This is exposed for use by the HMAC class which needs to know the
51 * block size for the [Hash] it is using. 51 * block size for the [Hash] it is using.
52 */ 52 */
53 int get blockSize; 53 int get blockSize;
54 } 54 }
55 55
56 /** 56 /**
57 * SHA1 hash function implementation. 57 * SHA1 hash function implementation.
58 */ 58 */
59 abstract class SHA1 implements Hash { 59 class SHA1 implements Hash {
60 factory SHA1() => new _SHA1(); 60 factory SHA1() => new _SHA1();
61 } 61 }
62 62
63 /** 63 /**
64 * SHA256 hash function implementation. 64 * SHA256 hash function implementation.
65 */ 65 */
66 abstract class SHA256 implements Hash { 66 class SHA256 implements Hash {
67 factory SHA256() => new _SHA256(); 67 factory SHA256() => new _SHA256();
68 } 68 }
69 69
70 /** 70 /**
71 * MD5 hash function implementation. 71 * MD5 hash function implementation.
72 * 72 *
73 * WARNING: MD5 has known collisions and should only be used when 73 * WARNING: MD5 has known collisions and should only be used when
74 * required for backwards compatibility. 74 * required for backwards compatibility.
75 */ 75 */
76 abstract class MD5 implements Hash { 76 class MD5 implements Hash {
77 factory MD5() => new _MD5(); 77 factory MD5() => new _MD5();
78 } 78 }
79 79
80 /** 80 /**
81 * Hash-based Message Authentication Code support. 81 * Hash-based Message Authentication Code support.
82 * 82 *
83 * The [add] method is used to add data to the message. The [digest] and 83 * The [add] method is used to add data to the message. The [digest] and
84 * [close] methods are used to extract the message authentication code. 84 * [close] methods are used to extract the message authentication code.
85 */ 85 */
86 // TODO(floitsch): make Hash implement Sink, EventSink or similar. 86 // TODO(floitsch): make Hash implement Sink, EventSink or similar.
87 abstract class HMAC { 87 class HMAC {
88 /** 88 /**
89 * Create an [HMAC] object from a [Hash] and a key. 89 * Create an [HMAC] object from a [Hash] and a key.
90 */ 90 */
91 factory HMAC(Hash hash, List<int> key) => new _HMAC(hash, key); 91 factory HMAC(Hash hash, List<int> key) => new _HMAC(hash, key);
92 92
93 /** 93 /**
94 * Add a list of bytes to the message. 94 * Add a list of bytes to the message.
95 */ 95 */
96 add(List<int> data); 96 add(List<int> data);
97 97
(...skipping 17 matching lines...) Expand all
115 * 115 *
116 * Throws an exception if the given digest does not have the same 116 * Throws an exception if the given digest does not have the same
117 * size as the digest computed by this HMAC instance. 117 * size as the digest computed by this HMAC instance.
118 */ 118 */
119 bool verify(List<int> digest); 119 bool verify(List<int> digest);
120 } 120 }
121 121
122 /** 122 /**
123 * Utility methods for working with message digests. 123 * Utility methods for working with message digests.
124 */ 124 */
125 abstract class CryptoUtils { 125 class CryptoUtils {
126 /** 126 /**
127 * Convert a list of bytes (for example a message digest) into a hex 127 * Convert a list of bytes (for example a message digest) into a hex
128 * string. 128 * string.
129 */ 129 */
130 static String bytesToHex(List<int> bytes) { 130 static String bytesToHex(List<int> bytes) {
131 return _CryptoUtils.bytesToHex(bytes); 131 return _CryptoUtils.bytesToHex(bytes);
132 } 132 }
133 133
134 /** 134 /**
135 * Converts a list of bytes into a Base 64 encoded string. 135 * Converts a list of bytes into a Base 64 encoded string.
(...skipping 26 matching lines...) Expand all
162 * 162 *
163 * Accepts both URL safe and unsafe Base 64 encoded strings. 163 * Accepts both URL safe and unsafe Base 64 encoded strings.
164 * 164 *
165 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648) 165 * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648)
166 */ 166 */
167 static List<int> base64StringToBytes(String input, 167 static List<int> base64StringToBytes(String input,
168 {bool ignoreInvalidCharacters : true}) { 168 {bool ignoreInvalidCharacters : true}) {
169 return _CryptoUtils.base64StringToBytes(input, ignoreInvalidCharacters); 169 return _CryptoUtils.base64StringToBytes(input, ignoreInvalidCharacters);
170 } 170 }
171 } 171 }
172
173 /**
174 * HashExceptions are thrown on invalid use of a Hash
175 * object.
176 */
177 class HashException {
178 HashException(String this.message);
179 toString() => "HashException: $message";
180 String message;
181 }
182
OLDNEW
« no previous file with comments | « no previous file | pkg/crypto/lib/src/crypto_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698