mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-25 15:15:23 +03:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97544530c9 | ||
|
|
0de51a2dea | ||
|
|
3b7b0a45e6 | ||
|
|
3a0b612239 | ||
|
|
e073b2babf | ||
|
|
83832f3e2c | ||
|
|
ee40ba1439 | ||
|
|
3f32990499 |
No files matched your search
+4
-1
@@ -47,6 +47,7 @@
|
||||
"@vueuse/core": "^10.3.0",
|
||||
"@vueuse/head": "^1.0.0",
|
||||
"@vueuse/router": "^10.0.0",
|
||||
"apache-md5": "^1.1.8",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"change-case": "^4.1.2",
|
||||
"colord": "^2.9.3",
|
||||
@@ -64,7 +65,6 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"image-to-ascii-art": "^0.0.4",
|
||||
"json5": "^2.2.3",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"libphonenumber-js": "^1.10.28",
|
||||
@@ -82,6 +82,7 @@
|
||||
"plausible-tracker": "^0.3.8",
|
||||
"qrcode": "^1.5.1",
|
||||
"sql-formatter": "^13.0.0",
|
||||
"sshpk": "^1.18.0",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"ulid": "^2.3.0",
|
||||
"unicode-emoji-json": "^0.4.0",
|
||||
@@ -111,6 +112,7 @@
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/node-forge": "^1.3.2",
|
||||
"@types/qrcode": "^1.5.0",
|
||||
"@types/sshpk": "^1.17.4",
|
||||
"@types/ua-parser-js": "^0.7.36",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@unocss/eslint-config": "^0.57.0",
|
||||
@@ -132,6 +134,7 @@
|
||||
"unplugin-icons": "^0.17.0",
|
||||
"unplugin-vue-components": "^0.25.0",
|
||||
"vite": "^4.4.9",
|
||||
"vite-plugin-node-polyfills": "^0.21.0",
|
||||
"vite-plugin-pwa": "^0.16.0",
|
||||
"vite-plugin-vue-markdown": "^0.23.5",
|
||||
"vite-svg-loader": "^4.0.0",
|
||||
|
||||
Generated
+642
-14
File diff suppressed because it is too large.
Load diff
@@ -16,6 +16,7 @@ const props = withDefaults(
|
||||
language?: string
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||
copyMessage?: string
|
||||
wordWrap?: boolean
|
||||
}>(),
|
||||
{
|
||||
followHeightOf: null,
|
||||
@@ -47,7 +48,7 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
|
||||
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
|
||||
>
|
||||
<n-config-provider :hljs="hljs">
|
||||
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
|
||||
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
|
||||
</n-config-provider>
|
||||
</n-scrollbar>
|
||||
<div absolute right-10px top-10px>
|
||||
|
||||
@@ -28,7 +28,7 @@ const compareMatch = computed(() => compareSync(compareString.value, compareHash
|
||||
mb-2
|
||||
/>
|
||||
<n-form-item label="Salt count: " label-placement="left" label-width="120">
|
||||
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
|
||||
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="10" :min="0" w-full />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text :value="hashed" readonly text-center />
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { hashSync } from 'bcryptjs';
|
||||
import md5 from 'apache-md5';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
|
||||
const username = ref('');
|
||||
const password = ref('');
|
||||
const hashMethod = ref('bcrypt');
|
||||
const saltCount = ref(10);
|
||||
|
||||
const htpasswd = computed(() => {
|
||||
if (username.value === '' || password.value === '') {
|
||||
return '# username and password must not be empty';
|
||||
}
|
||||
let hash;
|
||||
if (hashMethod.value === 'md5') {
|
||||
hash = md5(password.value);
|
||||
}
|
||||
else {
|
||||
hash = hashSync(password.value, saltCount.value);
|
||||
}
|
||||
return `${username.value}:${hash}`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-input-text
|
||||
v-model:value="username"
|
||||
label="Username"
|
||||
placeholder="Your username..."
|
||||
clearable raw-text mb-5
|
||||
/>
|
||||
<c-input-text
|
||||
v-model:value="password"
|
||||
label="Password"
|
||||
placeholder="Your password..."
|
||||
clearable
|
||||
raw-text
|
||||
mb-2
|
||||
type="password"
|
||||
/>
|
||||
|
||||
<c-select
|
||||
v-model:value="hashMethod"
|
||||
label="Hash method:"
|
||||
:options="['bcrypt', 'md5']"
|
||||
/>
|
||||
|
||||
<n-form-item v-if="hashMethod === 'bcrypt'" label="Salt count: " label-placement="left" label-width="120">
|
||||
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
|
||||
</n-form-item>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-form-item label="htpasswd content:">
|
||||
<TextareaCopyable :value="htpasswd" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
import { PasswordRound } from '@vicons/material';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Htpasswd/htaccess generator',
|
||||
path: '/htpasswd-generator',
|
||||
description: 'htpassword/htaccess user/password generator',
|
||||
keywords: ['htpasswd', 'htaccess', 'bcrypt', 'password'],
|
||||
component: () => import('./htpasswd-generator.vue'),
|
||||
icon: PasswordRound,
|
||||
createdAt: new Date('2024-02-20'),
|
||||
});
|
||||
@@ -1,25 +0,0 @@
|
||||
declare module 'image-to-ascii-art' {
|
||||
interface ConfigInterface {
|
||||
// the integer of pixels drawn on the canvas.
|
||||
// it sets bigger,the generated ascii art will be more detailed.
|
||||
// it has two type to set:
|
||||
// 1. (0, 1] decimal.result is that this number multiplied by the number of pixels in the original image
|
||||
// 2. An integer greater than 1.
|
||||
drawWidth?: number;
|
||||
drawHeight?: number;
|
||||
// the integer that pick one for every how many pixels.
|
||||
// it must be an integer greater than 0.
|
||||
pickDensityHorizontal?: number;
|
||||
pickDensityVertical?: number;
|
||||
// set the char of every grey range.
|
||||
greyRangeChar?: GreyRangeChar[];
|
||||
// if a grey value can't match one of the 'greyRangeChar' config,use this char.
|
||||
defaultGreyChar?: string;
|
||||
}
|
||||
|
||||
class ImageToAsciiArt {
|
||||
constructor({ canvas, config = {} }: { canvas?: HTMLCanvasElement; config?: ConfigInterface } = {})
|
||||
public convert(image: string | HTMLImageElement): Promise<string>
|
||||
public destroy(): void
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { ImageToAsciiArt } from 'image-to-ascii-art';
|
||||
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||
import { languages, translateToLanguage } from '@/utils/ascii-lang-utils';
|
||||
|
||||
const inputBase64 = ref('');
|
||||
const language = useStorage('image-to-ascii-art:language', 'raw');
|
||||
const scale = ref(100);
|
||||
const errored = ref(false);
|
||||
const processing = ref(false);
|
||||
|
||||
function toBase64(file: File) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = () => resolve(reader.result?.toString() ?? '');
|
||||
reader.onerror = error => reject(error);
|
||||
});
|
||||
}
|
||||
|
||||
const languagesOptions = languages.map(lang => ({ value: lang.id, label: lang.name }));
|
||||
|
||||
const output = computedAsync(async () => {
|
||||
const inputBase64Value = inputBase64.value;
|
||||
if (!inputBase64Value) {
|
||||
return '';
|
||||
}
|
||||
const scaleValue = scale.value / 100.0;
|
||||
const languageValue = language.value;
|
||||
|
||||
let outputValue = '';
|
||||
processing.value = true;
|
||||
try {
|
||||
errored.value = false;
|
||||
|
||||
const imageToAsciiArt = new ImageToAsciiArt({
|
||||
config: {
|
||||
drawWidth: scaleValue,
|
||||
drawHeight: scaleValue * 0.4,
|
||||
},
|
||||
});
|
||||
outputValue = translateToLanguage(await imageToAsciiArt.convert(inputBase64Value), languageValue);
|
||||
imageToAsciiArt.destroy();
|
||||
}
|
||||
catch (e) {
|
||||
errored.value = true;
|
||||
}
|
||||
processing.value = false;
|
||||
|
||||
return outputValue;
|
||||
});
|
||||
|
||||
async function onFileUploaded(uploadedFile: File) {
|
||||
inputBase64.value = await toBase64(uploadedFile);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card style="max-width: 600px;">
|
||||
<div style="flex: 0 0 100%">
|
||||
<div mx-auto max-w-600px>
|
||||
<c-file-upload
|
||||
title="Drag and drop a Image file here, or click to select a file"
|
||||
paste-image
|
||||
@file-upload="onFileUploaded"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<n-form-item label="Output scale" label-placement="left" mt-2>
|
||||
<n-slider v-model:value="scale" :step="1" :min="1" :max="100" mr-2 />
|
||||
<n-input-number v-model:value="scale" size="small" :min="1" :max="100" />
|
||||
</n-form-item>
|
||||
|
||||
<c-select v-model:value="language" :options="languagesOptions" searchable mt-3 />
|
||||
|
||||
<n-divider />
|
||||
|
||||
<div v-if="processing" flex items-center justify-center>
|
||||
<n-spin size="medium" />
|
||||
<span class="ml-2">Processing...</span>
|
||||
</div>
|
||||
|
||||
<c-alert v-if="errored" mt-1 text-center type="error">
|
||||
Current settings resulted in error.
|
||||
</c-alert>
|
||||
|
||||
<n-form-item v-if="!processing && !errored" label="Ascii Art text:">
|
||||
<TextareaCopyable
|
||||
:value="output"
|
||||
mb-1 mt-1
|
||||
copy-placement="outside"
|
||||
/>
|
||||
</n-form-item>
|
||||
</c-card>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
.n-code pre {
|
||||
font-size: 0.2em !important;
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Artboard } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Image to ASCII Art',
|
||||
path: '/image-to-ascii-art',
|
||||
description: 'Image to ASCII Art Generator',
|
||||
keywords: ['image', 'ascii', 'art'],
|
||||
component: () => import('./image-to-ascii-art.vue'),
|
||||
icon: Artboard,
|
||||
createdAt: new Date('2024-03-15'),
|
||||
});
|
||||
+3
-8
@@ -5,8 +5,8 @@ import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as htpasswdGenerator } from './htpasswd-generator';
|
||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||
import { tool as imageToAsciiArt } from './image-to-ascii-art';
|
||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||
@@ -118,6 +118,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
urlParser,
|
||||
deviceInformation,
|
||||
basicAuthGenerator,
|
||||
htpasswdGenerator,
|
||||
metaTagGenerator,
|
||||
otpCodeGeneratorAndValidator,
|
||||
mimeTypes,
|
||||
@@ -133,13 +134,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Images and videos',
|
||||
components: [
|
||||
qrCodeGenerator,
|
||||
wifiQrCodeGenerator,
|
||||
svgPlaceholderGenerator,
|
||||
cameraRecorder,
|
||||
imageToAsciiArt,
|
||||
],
|
||||
components: [qrCodeGenerator, wifiQrCodeGenerator, svgPlaceholderGenerator, cameraRecorder],
|
||||
},
|
||||
{
|
||||
name: 'Development',
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
function escapeXml(unsafe: string) {
|
||||
return unsafe.replace(/[<>&'"]/g, (c: string) => {
|
||||
switch (c) {
|
||||
case '<': return '<';
|
||||
case '>': return '>';
|
||||
case '&': return '&';
|
||||
case '\'': return ''';
|
||||
case '"': return '"';
|
||||
}
|
||||
return c;
|
||||
});
|
||||
}
|
||||
|
||||
const dontEscape = '';
|
||||
const escapeBackslash = '\\\\';
|
||||
const escapeSingleQuote = '\'';
|
||||
const escapeDoubleQuote = '"';
|
||||
const defaultEscape = escapeBackslash + escapeSingleQuote + escapeDoubleQuote;
|
||||
export const languages = [
|
||||
{ id: 'raw', name: 'Raw Text', prefix: '', suffix: '', begin: '', end: '', escape: dontEscape },
|
||||
{ id: 'bash', name: 'Bash', prefix: 'echo "', suffix: '"', begin: '', end: '', escape: escapeBackslash + escapeDoubleQuote },
|
||||
{ id: 'pwsh', name: 'PowerShell', prefix: 'Write-Output \'', suffix: '\'', begin: '', end: '', escape: escapeBackslash + escapeSingleQuote },
|
||||
{ id: 'c', name: 'C', prefix: 'printf("', suffix: '\\n");', begin: '#include <stdio.h>\n', end: '', escape: defaultEscape },
|
||||
{ id: 'cpp', name: 'C++', prefix: 'std::cout << "', suffix: '\\n";', begin: '#include <iostream>\n', end: '', escape: defaultEscape },
|
||||
{ id: 'csharp', name: 'C#', prefix: 'Console.WriteLine(@"', suffix: '");', begin: 'using System;\n', end: '', escape: escapeDoubleQuote },
|
||||
{ id: 'vbnet', name: 'VB.Net', prefix: 'Console.WriteLine("', suffix: '")', begin: '', end: '', escape: (l: string) => l.replace('"', '""') },
|
||||
{ id: 'node', name: 'Node.js', prefix: 'console.log("', suffix: '");', begin: '', end: '', escape: defaultEscape },
|
||||
{ id: 'python', name: 'Python', prefix: 'print("', suffix: '")', begin: '', end: '', escape: escapeBackslash + escapeDoubleQuote },
|
||||
{ id: 'html', name: 'HTML', prefix: '', suffix: '', begin: '<pre>\n', end: '\n</pre>', escape: (l: string) => escapeXml(l) },
|
||||
{ id: 'rust', name: 'Rust', prefix: 'println!("', suffix: '");', begin: '', end: '', escape: defaultEscape },
|
||||
{ id: 'go', name: 'Go', prefix: 'fmt.Println("', suffix: '")', begin: 'import "fmt"\n', end: '', escape: defaultEscape },
|
||||
{ id: 'ruby', name: 'Ruby', prefix: 'puts "', suffix: '"', begin: '', end: '', escape: defaultEscape },
|
||||
{ id: 'php', name: 'PHP', prefix: 'echo "', suffix: '\\n";', begin: '<?php\n', end: '\n?>', escape: defaultEscape },
|
||||
{ id: 'swift', name: 'Swift', prefix: 'print("', suffix: '")', begin: '', end: '', escape: defaultEscape },
|
||||
{ id: 'kotlin', name: 'Kotlin', prefix: 'println("', suffix: '")', begin: '', end: '', escape: defaultEscape },
|
||||
{ id: 'sql', name: 'SQL', prefix: 'SELECT \'', suffix: '\\n\'', begin: '', end: '', escape: (l: string) => l.replace('\'', '\'\'') },
|
||||
{ id: 'java', name: 'Java', prefix: 'System.out.println("', suffix: '");', begin: '', end: '', escape: defaultEscape },
|
||||
];
|
||||
export function translateToLanguage(asciiArt: string, languageId: string) {
|
||||
const langConfig = languages.find(l => l.id === languageId);
|
||||
if (!langConfig) {
|
||||
return asciiArt;
|
||||
}
|
||||
|
||||
const escape = typeof langConfig.escape === 'function'
|
||||
? langConfig.escape
|
||||
: function (line: string) {
|
||||
return langConfig.escape
|
||||
? line.replace(new RegExp(`([${langConfig.escape}])`, 'g'), '\\$1')
|
||||
: line;
|
||||
};
|
||||
return langConfig.begin + asciiArt.split('\n').map((line) => {
|
||||
return langConfig.prefix + escape(line) + langConfig.suffix;
|
||||
}).join('\n') + langConfig.end;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { URL, fileURLToPath } from 'node:url';
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
||||
|
||||
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
@@ -97,6 +98,7 @@ export default defineConfig({
|
||||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||
}),
|
||||
Unocss(),
|
||||
nodePolyfills(),
|
||||
],
|
||||
base: baseUrl,
|
||||
resolve: {
|
||||
|
||||
Reference in new issue
Block a user