Advertisement
metalx1000

Generate UUID

Jan 9th, 2025 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.55 KB | None | 0 0
  1. # Generate a UUID
  2. uuidgen
  3.  
  4. # using a string as a seed to produce the same UUID each time
  5. echo -n "unique_string" | openssl dgst -sha256 | sed 's/.* //' | cut -c1-36
  6.  
  7. # dashes are part of the standard, so lets add them
  8. echo -n "unique_string" | openssl dgst -sha256 | sed 's/.* //' | cut -c1-36| sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/'
  9.  
  10. # using sha256sum (which is in busybox) - also removes the need for the first sed command
  11. echo -n "unique_string" |sha256sum | cut -c1-36| sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement