From 59975e3aaa1083c574ca934ee618ecd5bdbdfc96 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 18 Jan 2016 13:39:50 +0000 Subject: [PATCH] Add missing keys class --- src/Composer/Util/Keys.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Composer/Util/Keys.php diff --git a/src/Composer/Util/Keys.php b/src/Composer/Util/Keys.php new file mode 100644 index 000000000..19628f5d3 --- /dev/null +++ b/src/Composer/Util/Keys.php @@ -0,0 +1,38 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Util; + +use Composer\Config; + +/** + * @author Jordi Boggiano + */ +class Keys +{ + public static function fingerprint($path) + { + $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path)))); + + return implode(' ', [ + substr($hash, 0, 8), + substr($hash, 8, 8), + substr($hash, 16, 8), + substr($hash, 24, 8), + '', // Extra space + substr($hash, 32, 8), + substr($hash, 40, 8), + substr($hash, 48, 8), + substr($hash, 56, 8), + ]); + } +}