Skip to content

Commit

Permalink
Fix bug in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
merces committed Dec 7, 2022
1 parent be01abf commit 6c286a4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/crypto/bh_hashcrack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bh_hashcrack() {
# argc must be equals to 1
(( $# < 1 )) && return 1

# if '${HOME}/.config/bashacks/' not exist
# if '${HOME}/.config/bashacks/' does not exist
[[ ! -d "$BASHACKS_CACHEDIR" ]] && {
mkdir -p "$BASHACKS_CACHEDIR"
> "${BASHACKS_CACHEDIR}/hashes.db"
Expand All @@ -13,7 +13,7 @@ bh_hashcrack() {
local cache=

# cache search
cache=$(grep "${hash}:" "${BASHACKS_CACHEDIR}/hash")
cache=$(grep "${hash}:" "${BASHACKS_CACHEDIR}/hashes.db")

if [[ "$cache" ]]; then
# getting the plaintext that is hashed
Expand All @@ -27,9 +27,8 @@ bh_hashcrack() {

# saving data to cache
[[ "$res" ]] && \
echo "${hash}:$res" >> "${BASHACKS_CACHEDIR}/hash"
echo "${hash}:$res" >> "${BASHACKS_CACHEDIR}/hashes.db"
fi

echo "$res"

}

0 comments on commit 6c286a4

Please sign in to comment.