Skip to content

Commit

Permalink
open source triple des tools
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenweiwang1990 committed Nov 16, 2023
1 parent df92cb5 commit 5bcf5b2
Show file tree
Hide file tree
Showing 12 changed files with 20,214 additions and 0 deletions.
232 changes: 232 additions & 0 deletions triple-des-decryption/meta.locale.json

Large diffs are not rendered by default.

9,626 changes: 9,626 additions & 0 deletions triple-des-decryption/package-lock.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions triple-des-decryption/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"type": "module",
"scripts": {
"dev": "he3 dev",
"publish": "he3 publish",
"i18n": "he3 i18n",
"version": "he3 version"
},
"he3": {
"userId": "3e696ac5-0721-4558-8c21-5b501c27115e",
"name": "TripleDES Decryption",
"id": "tripledes-decryption",
"isPublic": true,
"relatedToolId": [
"tripledes-encryption"
],
"version": "1.0.4",
"description": "TripleDES Decryption Tool is a tool used to decrypt TripleDES encrypted data. It can decrypt data encrypted with TripleDES and convert it back to its original form.\n\nFeatures:\n\n1. Supports decryption of TripleDES encrypted data.\n\n2. Supports selection of encryption mode and padding method.\n\n3. Supports reading data from files and saving decrypted data to files.\n\n4. Supports automatic save option for quick loading of previous settings.\n\nUse cases:\n\n1. Data decryption: During data transmission, sensitive data may need to be encrypted for protection. After encrypting data with TripleDES encryption algorithm, TripleDES Decryption Tool can be used to decrypt it back to its original form.\n\n2. Data recovery: During data backup or migration, encrypted data may need to be recovered to its original form. TripleDES Decryption Tool can easily decrypt the data.\n\n3. Data analysis: During data analysis, encrypted data may need to be decrypted for better understanding of data structure and content. TripleDES Decryption Tool can easily decrypt the data.\n\n4. Data conversion: During data conversion, encrypted data may need to be decrypted to its original form. TripleDES Decryption Tool can easily complete the data conversion.",
"repository": "",
"icon": "unlock-outlined",
"category": [
"cryptography"
],
"keywords": [
"TripleDES",
"3des",
"des3",
"decryption",
"decrypt",
"symmetric",
"cbc",
"ecb",
"cfb",
"ctr",
"ofb",
"pkcs7",
"iso10126",
"ansix923",
"Symmetric Encryption"
]
},
"dependencies": {
"crypto-js": "^4.1.1",
"unescape-js": "^1.1.4",
"vue": "^3.2.45",
"vue-i18n": "^9.2.2"
},
"devDependencies": {
"@he3-kit/cli": "latest",
"@vitejs/plugin-vue": "^4.0.0",
"less": "^4.1.3",
"vite": "^4.0.0"
}
}
2 changes: 2 additions & 0 deletions triple-des-decryption/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Index from './index.vue';
export default Index;
167 changes: 167 additions & 0 deletions triple-des-decryption/src/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<template>
<h-text-transform
ref="cryptRef"
enable-file
:file-output-alert="t('dec')"
:sample-data="sample"
:transform="decrypt"
:file-output-name="fileName"
>
<template #option>
<a-space style="margin-top: 16px">
<span>{{ t('key') }}</span>
<h-input-password
v-model:value="keyString"
@change="callCryptMethod"
:save-options="{ autoSave: true, key: 'password' }"
/>
<span>{{ t('mode') }}</span>
<span>
<h-select
v-model:value="cipherType"
@change="callCryptMethod"
:save-options="{ key: 'cipherType', autoSave: true }"
>
<a-select-option :value="CipherType.CBC">
{{ CipherType.CBC }}
</a-select-option>
<a-select-option :value="CipherType.ECB">
{{ CipherType.ECB }}
</a-select-option>
<a-select-option :value="CipherType.CFB">
{{ CipherType.CFB }}
</a-select-option>
<a-select-option :value="CipherType.CTR">
{{ CipherType.CTR }}
</a-select-option>
<a-select-option :value="CipherType.OFB">
{{ CipherType.OFB }}
</a-select-option>
</h-select>
</span>
<span>{{ t('padding') }}</span>
<span>
<h-select
v-model:value="paddingType"
@change="callCryptMethod"
:save-options="{ key: 'paddingType', autoSave: true }"
>
<a-select-option :value="CipherType.Pkcs7">
{{ CipherType.Pkcs7 }}
</a-select-option>
<a-select-option :value="CipherType.Zero">
{{ CipherType.Zero }}
</a-select-option>
<a-select-option :value="CipherType.Iso10126">
{{ CipherType.Iso10126 }}
</a-select-option>
<a-select-option :value="CipherType.None">
{{ CipherType.None }}
</a-select-option>
<a-select-option :value="CipherType.Ansix923">
{{ CipherType.Ansix923 }}
</a-select-option>
</h-select>
</span>
</a-space>
</template>
</h-text-transform>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import CryptoJS from 'crypto-js';
import { useI18n } from 'vue-i18n';
import messages from './lang.json';
const { t } = useI18n({
locale: window.$he3.lang,
messages,
});
const enum CipherType {
ECB = 'ECB',
CBC = 'CBC',
CFB = 'CFB',
CTR = 'CTR',
OFB = 'OFB',
// padding
Pkcs7 = 'Pkcs7',
Zero = 'Zero',
Iso10126 = 'Iso10126',
None = 'None',
Ansix923 = 'Ansix923',
}
const sample =
'U2FsdGVkX18HpYZQ95oEyhayXGAmObpId4QGqT92taD+stjnZQcNLtxffoCr0fsPY5dz0TxtlrwXbkcU4nz3Rg==';
const keyString = ref('key');
const cipherType = ref(CipherType.CBC);
const paddingType = ref(CipherType.Pkcs7);
const cryptRef = ref();
const callCryptMethod = () => {
cryptRef.value.handleChange();
};
const decrypt = (rawValue: string) => {
if (rawValue.length <= 0) {
window.$he3.message.warn('Please enter the plain text');
return '';
}
if (keyString.value.length <= 0) {
window.$he3.message.warn('Please enter the key');
return '';
}
const cipherOps = {
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
};
switch (cipherType.value) {
case CipherType.ECB:
cipherOps.mode = CryptoJS.mode.ECB;
break;
case CipherType.CFB:
cipherOps.mode = CryptoJS.mode.CFB;
break;
case CipherType.CTR:
cipherOps.mode = CryptoJS.mode.CTR;
break;
case CipherType.OFB:
cipherOps.mode = CryptoJS.mode.OFB;
break;
}
switch (paddingType.value) {
case CipherType.Zero:
cipherOps.padding = CryptoJS.pad.ZeroPadding;
break;
case CipherType.Iso10126:
cipherOps.padding = CryptoJS.pad.Iso10126;
break;
case CipherType.None:
cipherOps.padding = CryptoJS.pad.NoPadding;
break;
case CipherType.Ansix923:
cipherOps.padding = CryptoJS.pad.AnsiX923;
break;
}
try {
const ripeValue = CryptoJS.TripleDES.decrypt(rawValue, keyString.value, cipherOps).toString(
CryptoJS.enc.Utf8
);
return ripeValue;
} catch (error) {
window.$he3.message.error(error.message);
return '';
}
};
/** 返回函数名,加密文件添加enc后缀 */
const fileName = (fileName: string) => {
const fileArr = fileName.split('.');
if (fileArr.at(-1) === 'enc') fileArr.pop();
fileArr.splice(-1, 0, 'dec');
return fileArr.join('.');
};
</script>
79 changes: 79 additions & 0 deletions triple-des-decryption/src/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"zh": {
"enc": "文件加密成功,点击按钮输出文件",
"dec": "文件解密成功,点击按钮输出文件",
"key": "密钥:",
"mode": "模式:",
"padding": "填充:"
},
"en": {
"enc": "The file is encrypted successfully. Click the button to output the file",
"dec": "The file is decrypted successfully. Click the button to output the file",
"key": "Passphrase:",
"mode": "Mode:",
"padding": "Padding:"
},
"de": {
"enc": "Die Dateiverschlüsselung ist erfolgreich. Klicken Sie auf die Schaltfläche, um die Datei auszugeben",
"dec": "Die Dateientschlüsselung ist erfolgreich. Klicken Sie auf die Schaltfläche, um die Datei auszugeben",
"key": "Taste:",
"mode": "Modell:",
"padding": "Füllung:"
},
"es": {
"enc": "El cifrado de archivo es exitoso, haga clic en el botón para emitir el archivo",
"dec": "El descifrado del archivo es exitoso, haga clic en el botón para emitir el archivo",
"key": "Llave:",
"mode": "modelo:",
"padding": "relleno:"
},
"fr": {
"enc": "Le chiffrement du fichier est réussi, cliquez sur le bouton pour sortir le fichier",
"dec": "Le décryptage du fichier réussit, cliquez sur le bouton pour sortir le fichier",
"key": "Clé:",
"mode": "modèle:",
"padding": "remplissage:"
},
"it": {
"enc": "La crittografia del file ha esito positivo, fare clic sul pulsante per emettere il file",
"dec": "La decryption del file ha esito positivo, fai clic sul pulsante per output del file",
"key": "Chiave:",
"mode": "modello:",
"padding": "Riempimento:"
},
"ja": {
"enc": "ファイルの暗号化が成功しました。ボタンをクリックしてファイルを出力します。",
"dec": "ファイルの復号化が成功しました。ボタンをクリックしてファイルを出力します。",
"key": "鍵:",
"mode": "モデル:",
"padding": "充填:"
},
"ko": {
"enc": "파일 암호화가 성공적이면 버튼을 클릭하여 파일을 출력합니다.",
"dec": "파일 암호 해독이 성공적이면 버튼을 클릭하여 파일을 출력합니다.",
"key": "열쇠:",
"mode": "모델:",
"padding": "충전재:"
},
"pt": {
"enc": "A criptografia de arquivo é bem -sucedida, clique no botão para emitir o arquivo",
"dec": "A descriptografia do arquivo é bem -sucedida, clique no botão para emitir o arquivo",
"key": "Chave:",
"mode": "modelo:",
"padding": "enchimento:"
},
"ru": {
"enc": "Шифрование файла успешно, нажмите кнопку, чтобы вывести файл",
"dec": "Дешифрование файла успешно, нажмите кнопку, чтобы вывести файл",
"key": "Ключ:",
"mode": "модель:",
"padding": "начинка:"
},
"zh-tw": {
"enc": "文件加密成功,點擊按鈕輸出文件",
"dec": "文件解密成功,點擊按鈕輸出文件",
"key": "密鑰:",
"mode": "模式:",
"padding": "填充:"
}
}
Loading

0 comments on commit 5bcf5b2

Please sign in to comment.