Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. USAGE="$0 SOURCE_FILE MSG_SIZE MSG_COUNT
  4.  
  5. with:
  6. SOURCE_FILE the file from which the random binary is read
  7. MSG _SIZE the size in characters of each message
  8. MSG _COUNT the number of messages produced in a file
  9. "
  10.  
  11. SOURCE_FILE=$1
  12. MSG_SIZE=$2
  13. MSG_COUNT=$3
  14.  
  15. if [ -z $SOURCE_FILE ] || [ -z $MSG_SIZE ] || [ -z $MSG_COUNT ]
  16. then
  17. echo 'ERROR: Missing argument'
  18. echo $USAGE
  19. exit 1
  20. fi
  21.  
  22. base64 -w $MSG_SIZE $SOURCE_FILE | head -n $MSG_COUNT | {
  23.  
  24. i=1
  25. while read line
  26. do
  27.  
  28. sha=$(echo $line | sha512sum | cut -d ' ' -f 1)
  29. echo "$i|$sha|$line"
  30. i=$(($i + 1))
  31.  
  32. done
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement