Skip to content

Commit

Permalink
feat(pickAlgo): pick the strongest algorithm provided, by default
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ssri will prioritize specific hashes now
  • Loading branch information
zkat committed Mar 24, 2017
1 parent 8d3605b commit 58c18f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ function createCheckerStream (sri, opts) {
return stream
}

// This is a Best Effort™ at a reasonable priority for hash algos
const DEFAULT_PRIORITY = [
'md5', 'whirlpool', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'
]
function getPrioritizedHash (algo1, algo2) {
return algo1
return DEFAULT_PRIORITY.indexOf(algo1.toLowerCase()) >= DEFAULT_PRIORITY.indexOf(algo2.toLowerCase())
? algo1
: algo2
}

0 comments on commit 58c18f7

Please sign in to comment.