Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Add user-defined hash algorithms
Browse files Browse the repository at this point in the history
- Changing function name to be more specific / unique
- Adding $algorithm as defined in `config.php`
  • Loading branch information
S1SYPHOS committed Oct 31, 2017
1 parent 89ec109 commit 7335999
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kirby-sri.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

if(!c::get('sri-hash')) return;

function checksum($input) {
public function sri_checksum($input) {
$algorithm = c::get('sri-hash.algorithm') ? c::get('sri-hash.algorithm') : 'sha512';
$hash = hash('sha512', $input, true);
$hash_base64 = base64_encode($hash);

return "sha512-$hash_base64";
return "$algorithm-$hash_base64";
}

load([
Expand Down

0 comments on commit 7335999

Please sign in to comment.