-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
432 additions
and
157 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,8 @@ CaptfEncoder是一款可扩展跨平台网络安全工具套件,提供网络 | |
* 实用工具 | ||
* 图片Exif | ||
* Hash类型识别 | ||
* File Type | ||
* File Hash | ||
|
||
|
||
## 项目网站 | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File hash | ||
=========== | ||
|
34 changes: 34 additions & 0 deletions
34
extensions/ext.app.misc.file-hash/controllers/ext.app.misc.file-crc32.get.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
const defaultValue = require('../../ext.common/default-value'); | ||
|
||
const {crc32}= require("crc"); | ||
|
||
module.exports = async function (input, options = {}) { | ||
|
||
try { | ||
let output = ''; | ||
|
||
if (input && input.data) { | ||
const result = crc32(Buffer.from(input.data)); | ||
|
||
if (result) { | ||
output = result; | ||
} | ||
} | ||
|
||
return { | ||
success: true, | ||
output: output, | ||
}; | ||
} | ||
catch (err) { | ||
return { | ||
success: false, | ||
output: '', | ||
message: err.message | ||
}; | ||
} | ||
|
||
} | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
extensions/ext.app.misc.file-hash/controllers/ext.app.misc.file-hash.get.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
const defaultValue = require('../../ext.common/default-value'); | ||
|
||
const crypto = require("crypto"); | ||
|
||
module.exports = async function (input, options = {}) { | ||
|
||
try { | ||
let output = ''; | ||
|
||
if (input && input.data) { | ||
|
||
const algorithm = defaultValue(options.algorithm, 'md5'); | ||
|
||
const hasher = crypto.createHash(algorithm); | ||
|
||
hasher.update(Buffer.from(input.data)); | ||
|
||
const result = hasher.digest("hex"); | ||
|
||
if (result) { | ||
output = result; | ||
} | ||
} | ||
|
||
return { | ||
success: true, | ||
output: output, | ||
}; | ||
} | ||
catch (err) { | ||
return { | ||
success: false, | ||
output: '', | ||
message: err.message | ||
}; | ||
} | ||
|
||
} | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
const options = { | ||
value: { | ||
algorithm: "md5", | ||
}, | ||
schema: { | ||
fields: [{ | ||
type: "select", | ||
label: "Algorithm", | ||
key: "algorithm", | ||
items: [{ | ||
text: "MD5", | ||
value: "md5" | ||
}, { | ||
text: "SHA1", | ||
value: "sha1" | ||
}, { | ||
text: "SHA224", | ||
value: "sha224" | ||
}, { | ||
text: "SHA256", | ||
value: "sha256" | ||
}, { | ||
text: "SHA384", | ||
value: "sha384" | ||
}, { | ||
text: "SHA512", | ||
value: "sha512" | ||
}, { | ||
text: "CRC32", | ||
value: "crc32" | ||
},], | ||
cols: 3 | ||
|
||
}] | ||
|
||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
name: 'getter', | ||
data() { | ||
return { | ||
loading: false, | ||
file: '', | ||
output: '', | ||
options: options.value, | ||
schema: options.schema | ||
} | ||
}, | ||
template: ` | ||
<v-container fluid class="ma-2"> | ||
<ext-loading absolute :show="loading"></ext-loading> | ||
<ext-form :model="options" :schema="schema"> | ||
</ext-form> | ||
<v-row height="40" > | ||
<v-toolbar flat > | ||
<v-text-field type="text" :value="file" outline readonly label="File"> | ||
<template v-slot:append-outer> | ||
<v-btn elevation="2" @click="openFile" text >Select...</v-btn> | ||
</template> | ||
</v-text-field> | ||
</v-toolbar> | ||
</v-row> | ||
<v-row> | ||
<v-col> | ||
<ext-editor v-model="output" readonly> | ||
</ext-editor> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
`, | ||
watch: { | ||
options: { | ||
async handler(newValue) { | ||
await this.invoke(); | ||
}, | ||
deep: true, | ||
}, | ||
}, | ||
methods: { | ||
async openFile() { | ||
this.fileData = await this.$openFile('Open file'); | ||
|
||
await this.invoke(); | ||
}, | ||
|
||
async invoke() { | ||
if (this.fileData) { | ||
this.loading = true; | ||
|
||
this.file = this.fileData.file; | ||
|
||
let result; | ||
|
||
if (this.options.algorithm === "md5" | ||
|| this.options.algorithm === "sha1" | ||
|| this.options.algorithm === "sha224" | ||
|| this.options.algorithm === "sha256" | ||
|| this.options.algorithm === "sha384" | ||
|| this.options.algorithm === "sha512") { | ||
result = await this.$extInvoke('ext.app.misc.file-hash.get', this.fileData, this.options); | ||
} else if (this.options.algorithm === "crc32") { | ||
result = await this.$extInvoke('ext.app.misc.file-crc32.get', this.fileData); | ||
} | ||
|
||
if (result && result.success) { | ||
this.output = result.output; | ||
} | ||
else { | ||
this.output = ''; | ||
this.$store.dispatch("showSnackbar", result.message); | ||
} | ||
|
||
this.loading = false; | ||
} else { | ||
this.file = ''; | ||
this.output = ''; | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "ext.app.misc.file-hash", | ||
"description": "File hash", | ||
"version": "1.0.0", | ||
"author": "guyoung", | ||
"url": "", | ||
"dependencies": { | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
const getter = require('./getter.component'); | ||
|
||
module.exports = { | ||
name: 'ext.app.misc.file-type.view.component', | ||
data() { | ||
return { | ||
tab: null, | ||
} | ||
}, | ||
components: { | ||
getter, | ||
}, | ||
template: ` | ||
<ext-tab title="File hash"> | ||
<v-container fluid> | ||
<getter /> | ||
</v-container> | ||
</ext-tab> | ||
`, | ||
methods: { | ||
|
||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
File type | ||
=========== | ||
|
34 changes: 34 additions & 0 deletions
34
extensions/ext.app.misc.file-type/controllers/ext.app.misc.file-type.get.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
const defaultValue = require('../../ext.common/default-value'); | ||
|
||
const fileType = require("file-type"); | ||
|
||
module.exports = async function (input, options = {}) { | ||
|
||
try { | ||
let output = ''; | ||
|
||
if (input && input.data) { | ||
const result = fileType(Buffer.from(input.data)); | ||
|
||
if (result) { | ||
output = `ext: ${result.ext}\nmime: ${result.mime}`; | ||
} | ||
} | ||
|
||
return { | ||
success: true, | ||
output: output, | ||
}; | ||
} | ||
catch (err) { | ||
return { | ||
success: false, | ||
output: '', | ||
message: err.message | ||
}; | ||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.