Skip to content

Commit 345aa6e

Browse files
committed
[HASHES]: refactored to new method
1 parent 71250d3 commit 345aa6e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/commands/hash.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export default class Hash extends Command {
3131
else
3232
str = args.string
3333

34+
this.calculateHash(type, str)
35+
}
36+
37+
private calculateHash(type: string, str: string) {
3438
let hash: Hashes
3539
switch (type.toUpperCase()) {
3640
case 'SHA1':
@@ -47,7 +51,12 @@ export default class Hash extends Command {
4751
hash = undefined
4852
}
4953

50-
let hashed: string = hash.hex(str)
51-
this.log(`[HASH]: ${hashed}`)
54+
if (hash) {
55+
let hashed: string = hash.hex(str)
56+
this.log(`[HASH]: ${hashed}`)
57+
} else {
58+
this.log('[ERROR]: invalid hash type')
59+
}
60+
5261
}
5362
}

0 commit comments

Comments
 (0)