PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/core/externals/update-engine/Samples/EngineRunner/kshash.sh

http://macfuse.googlecode.com/
Shell | 30 lines | 10 code | 4 blank | 16 comment | 2 complexity | 85f44728c72488db13f530ca0d8c2a4f MD5 | raw file
 1#!/bin/bash
 2# Copyright 2008 Google Inc.
 3#
 4# Licensed under the Apache License, Version 2.0 (the "License");
 5# you may not use this file except in compliance with the License.
 6# You may obtain a copy of the License at
 7#
 8#     http://www.apache.org/licenses/LICENSE-2.0
 9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# This script takes a list of file names as arguments and outputs
17# each file's base64 encoded SHA-1 hash.
18
19PATH=/bin:/usr/bin; export PATH
20
21if [ $# -eq 0 ]; then
22  echo "Usage: kshash.sh file1 ..."
23  exit 1
24fi
25
26for file in "$@"; do
27  h=$(openssl sha1 -binary "$file" | openssl base64)
28  s=$(stat -f%z "$file")
29  printf "%20s:\t%s\t%s\n" "$file" $h $s
30done