Last active
July 21, 2025 13:05
-
-
Save kepocnhh/f06a473539759f8a8d306b620affea48 to your computer and use it in GitHub Desktop.
openssl aes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # key | |
| openssl rand -hex 32 | |
| # iv | |
| openssl rand -hex 16 | |
| openssl enc -aes-256-cbc -P | |
| # salt=C0FDB84CFB4ED88F | |
| # key=1D5659F237383B18E22169C06C88DD452C61285D2D154ECCBE781A187DE5521D | |
| # iv =A85A73961775FEC214ECC7155B139D70 | |
| # Encrypt | |
| echo "$(date +%s)" | openssl enc -aes-256-cbc -e -out foo.txt.enc | |
| # Decrypt | |
| openssl enc -aes-256-cbc -d -in foo.txt.enc | |
| # Encrypt password based | |
| echo "$(date +%s)" | openssl enc -aes-256-cbc -e -out foo.txt.enc -pbkdf2 | |
| # Decrypt password based | |
| openssl enc -aes-256-cbc -d -in foo.txt.enc -pbkdf2 | |
| # Generate key | |
| # CIPHER='-aes-256-cbc' | |
| # IV='1e304f2203d044459722bfd88bf6078b' | |
| # SALT='00000198235ec470' | |
| # PASSWORD='dc301e15-5d68-4325-9bb5-b0fa8d96ae5e' | |
| # ITERATIONS=10000 | |
| openssl enc "${CIPHER}" -iv "${IV}" -S "${SALT}" -pass pass:"${PASSWORD}" -iter $ITERATIONS -P | |
| # KEY='5859f5228f39c530ede0a3a723e8fede52f25188abb70a583ced051df01a539d' | |
| # Decrypt with key | |
| openssl enc "${CIPHER}" -iv "${IV}" -K "${KEY}" -d -in foo.payload.enc | |
| # Generate key | |
| # CIPHER='-aes-256-ecb' | |
| # SALT='00000198235ec470' | |
| # PASSWORD='dc301e15-5d68-4325-9bb5-b0fa8d96ae5e' | |
| # ITERATIONS=10000 | |
| openssl enc "${CIPHER}" -S "${SALT}" -pass pass:"${PASSWORD}" -iter $ITERATIONS -P | |
| # KEY='5859f5228f39c530ede0a3a723e8fede52f25188abb70a583ced051df01a539d' | |
| # Decrypt without iv | |
| openssl enc "${CIPHER}" -K "${KEY}" -d -in foo.payload.enc | |
| # Create AES key | |
| openssl rand -hex 32 > foo.hex; cat foo.hex | |
| cat foo.hex | xxd -r -p > foo.bin; xxd -p -c 64 foo.bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment