/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. # This script takes a list of file names as arguments and outputs
  16. # each file's base64 encoded SHA-1 hash.
  17. PATH=/bin:/usr/bin; export PATH
  18. if [ $# -eq 0 ]; then
  19. echo "Usage: kshash.sh file1 ..."
  20. exit 1
  21. fi
  22. for file in "$@"; do
  23. h=$(openssl sha1 -binary "$file" | openssl base64)
  24. s=$(stat -f%z "$file")
  25. printf "%20s:\t%s\t%s\n" "$file" $h $s
  26. done