OLD | NEW |
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 #source("../../../../runtime/bin/sha1.dart"); | 5 #source("../../../runtime/bin/sha1.dart"); |
6 | 6 |
7 void hexifyHash(List<int> data) { | 7 void hexifyHash(List<int> data) { |
8 Expect.equals(20, data.length); | 8 Expect.equals(20, data.length); |
9 StringBuffer sb = new StringBuffer(); | 9 StringBuffer sb = new StringBuffer(); |
10 for (int i = 0; i < data.length; i++) { | 10 for (int i = 0; i < data.length; i++) { |
11 String s = data[i].toRadixString(16); | 11 String s = data[i].toRadixString(16); |
12 if (s.length == 1) sb.add("0"); | 12 if (s.length == 1) sb.add("0"); |
13 sb.add(s); | 13 sb.add(s); |
14 } | 14 } |
15 return sb.toString().toLowerCase(); | 15 return sb.toString().toLowerCase(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // From WebSocket standard. | 51 // From WebSocket standard. |
52 data = "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 52 data = "dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
53 Expect.equals("b37a4f2cc0624f1690f64606cf385945b2bec4ea", | 53 Expect.equals("b37a4f2cc0624f1690f64606cf385945b2bec4ea", |
54 hexifyHash(_Sha1._hash(data.charCodes()))); | 54 hexifyHash(_Sha1._hash(data.charCodes()))); |
55 | 55 |
56 data = "0123456789001234567890012345678900123456789001234567890" | 56 data = "0123456789001234567890012345678900123456789001234567890" |
57 "0123456789001234567890012345678900123456789001234567890"; | 57 "0123456789001234567890012345678900123456789001234567890"; |
58 Expect.equals("534e82e5600593484251f42bd4855561a234a14b", | 58 Expect.equals("534e82e5600593484251f42bd4855561a234a14b", |
59 hexifyHash(_Sha1._hash(data.charCodes()))); | 59 hexifyHash(_Sha1._hash(data.charCodes()))); |
60 } | 60 } |
OLD | NEW |