Skip to content

Commit

Permalink
refactor: Added explanations to the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
orlowskilp committed Jun 25, 2024
1 parent 558a83c commit 616e5b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pem2pubhex.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#!/bin/bash

cat $1 | head -3 | tail -2 | base64 --decode | xxd -c 0 -ps | tail -c 129
# Read content of file in the first argument and concatenate at terminal
cat $1 | \
# Retain only first 3 lines (i.e. remove "-----END PUBLIC KEY-----" line)
head -3 | \
# Retain only the last 2 lines (i.e. remove "-----BEGIN PUBLIC KEY----- line)
tail -2 | \
# Decode base64 to binary
base64 --decode | \
# Convert binary to hex as one line and print to terminal
xxd -c 0 -ps | \
# Retain only the last 129 characters (inclusive of EOL)
tail -c 129
11 changes: 10 additions & 1 deletion pubhex2evm.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#!/bin/bash

cat $1 | keccak-256sum -x -l | tr -d ' -' | tail -c 41 | xargs -I % echo 0x%
# Read content of file in the first argument and concatenate at terminal
cat $1 | \
# Compute Keccak256 sum of hexed public key literal and express in lowercase hexadecimal
keccak-256sum -x -l | \
# Remove the trailing "[:space:][:hyphen:]" characters
tr -d ' -' | \
# Retain only the last 41 characters (inclusive of EOL)
tail -c 41 | \
# Prepend the address with "0x"
xargs -I % echo 0x%

0 comments on commit 616e5b2

Please sign in to comment.