| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Defines the algorithms used by the isolated server. | 5 // Defines the algorithms used by the isolated server. |
| 6 | 6 |
| 7 package isolated | 7 package isolated |
| 8 | 8 |
| 9 import ( | 9 import ( |
| 10 "compress/zlib" | |
| 11 "crypto/sha1" | 10 "crypto/sha1" |
| 12 "hash" | 11 "hash" |
| 13 "io" | 12 "io" |
| 14 "log" | 13 "log" |
| 15 » // https://crbug.com/552697 | 14 |
| 16 » //"github.com/klauspost/compress/zlib" | 15 » // TODO(tandrii): this library became part of Go 1.7, So, switch back to |
| 16 » // standard library compress/zlib once we are solidly on Go > 1.7 |
| 17 » "github.com/klauspost/compress/zlib" |
| 17 ) | 18 ) |
| 18 | 19 |
| 19 var hashLength = sha1.New().Size() | 20 var hashLength = sha1.New().Size() |
| 20 | 21 |
| 21 // GetHash returns a fresh instance of the hashing algorithm to be used to | 22 // GetHash returns a fresh instance of the hashing algorithm to be used to |
| 22 // calculate the HexDigest. | 23 // calculate the HexDigest. |
| 23 // | 24 // |
| 24 // It is currently hardcoded to sha-1. | 25 // It is currently hardcoded to sha-1. |
| 25 func GetHash() hash.Hash { | 26 func GetHash() hash.Hash { |
| 26 return sha1.New() | 27 return sha1.New() |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 68 } |
| 68 return true | 69 return true |
| 69 } | 70 } |
| 70 | 71 |
| 71 // HexDigests is a slice of HexDigest that implements sort.Interface. | 72 // HexDigests is a slice of HexDigest that implements sort.Interface. |
| 72 type HexDigests []HexDigest | 73 type HexDigests []HexDigest |
| 73 | 74 |
| 74 func (h HexDigests) Len() int { return len(h) } | 75 func (h HexDigests) Len() int { return len(h) } |
| 75 func (h HexDigests) Less(i, j int) bool { return h[i] < h[j] } | 76 func (h HexDigests) Less(i, j int) bool { return h[i] < h[j] } |
| 76 func (h HexDigests) Swap(i, j int) { h[i], h[j] = h[j], h[i] } | 77 func (h HexDigests) Swap(i, j int) { h[i], h[j] = h[j], h[i] } |
| OLD | NEW |