Skip to content

Commit

Permalink
Merge pull request #6 from pplanel/feature/truncate_flag
Browse files Browse the repository at this point in the history
Feature/truncate flag
  • Loading branch information
pplanel authored Apr 27, 2021
2 parents ead9d0a + 91dc215 commit 5acf376
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/hash_calc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
with:
input: pplanel
method: SHA512
truncate: true
- name: print output
run: |
echo This is the output ${{steps.hash.outputs.digest}}
9 changes: 0 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,3 @@ jobs:
- uses: actions/checkout@v2
- run: npm ci
- run: npm test

# test action works running from the graph
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
with:
milliseconds: 1000
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
required: false
description: When choosing MD3(Keccak) you can optionally choose its output length. Default is 512 bits.
default: -1
truncate:
required: false
description: Truncate the output digest
default: false
outputs:
digest:
description: Generated hash based on input and hash method.
8 changes: 7 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let generator = function (hash_type, input_str, hash_output_length) {
if (['SHA3', 'SHA-3'].includes(hash_type)) {
const hashed_string = hash_algo(input_str, hash_output_length).toString()

resolve(hashed_string + 'asda')
resolve(hashed_string)
} else if(hash_output_length > 0){

throw new Error("output_len can only be set in SHA3 mode.");
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ async function run() {
const input = core.getInput('input');
const method = core.getInput('method');
const output_length = core.getInput('output_len');
const truncate = core.getInput('truncate');

let output_string = await generator(method, input, output_length)

if(truncate){
output_string = output_string.slice(0, 7)
}

core.setOutput('digest', output_string.toString());
} catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit 5acf376

Please sign in to comment.