feat(tool): text hash
This commit is contained in:
		
							parent
							
								
									40dec52c84
								
							
						
					
					
						commit
						0f3b7445ad
					
				
							
								
								
									
										72
									
								
								src/tools/hash-text/hash-text.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/tools/hash-text/hash-text.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | |||||||
|  | <template> | ||||||
|  |     <div> | ||||||
|  |         <n-card> | ||||||
|  |             <n-input | ||||||
|  |                 v-model:value="clearText" | ||||||
|  |                 type="textarea" | ||||||
|  |                 placeholder="Your string..." | ||||||
|  |                 :autosize="{ minRows: 3 }" | ||||||
|  |             /> | ||||||
|  |             <br /> | ||||||
|  |             <br /> | ||||||
|  |             <n-select | ||||||
|  |                 v-model:value="algo" | ||||||
|  |                 :options="Object.keys(algos).map(label => ({ label, value: label }))" | ||||||
|  |             /> | ||||||
|  | 
 | ||||||
|  |             <br /> | ||||||
|  |             <n-input | ||||||
|  |                 style="text-align: center;" | ||||||
|  |                 v-model:value="hashedText" | ||||||
|  |                 type="textarea" | ||||||
|  |                 placeholder="Your string hash" | ||||||
|  |                 :autosize="{ minRows: 1 }" | ||||||
|  |                 readonly | ||||||
|  |                 autocomplete="off" | ||||||
|  |                 autocorrect="off" | ||||||
|  |                 autocapitalize="off" | ||||||
|  |                 spellcheck="false" | ||||||
|  |             /> | ||||||
|  |             <br /> | ||||||
|  |             <br /> | ||||||
|  |             <n-space justify="center"> | ||||||
|  |                 <n-button @click="copy" secondary autofocus>Copy</n-button> | ||||||
|  |             </n-space> | ||||||
|  |         </n-card> | ||||||
|  |     </div> | ||||||
|  | </template> | ||||||
|  | 
 | ||||||
|  | <script setup lang="ts"> | ||||||
|  | import { useCopy } from '@/composable/copy'; | ||||||
|  | import { ref, computed } from 'vue' | ||||||
|  | import { | ||||||
|  |     MD5, | ||||||
|  |     SHA1, | ||||||
|  |     SHA256, | ||||||
|  |     SHA224, | ||||||
|  |     SHA512, | ||||||
|  |     SHA384, | ||||||
|  |     SHA3, | ||||||
|  |     RIPEMD160, | ||||||
|  | } from 'crypto-js' | ||||||
|  | 
 | ||||||
|  | const algos = { | ||||||
|  |     MD5, | ||||||
|  |     SHA1, | ||||||
|  |     SHA256, | ||||||
|  |     SHA224, | ||||||
|  |     SHA512, | ||||||
|  |     SHA384, | ||||||
|  |     SHA3, | ||||||
|  |     RIPEMD160, | ||||||
|  | } as const; | ||||||
|  | 
 | ||||||
|  | const clearText = ref('Lorem ipsum') | ||||||
|  | const hashedText = computed(() => algos[algo.value](clearText.value)) | ||||||
|  | const algo = ref<keyof typeof algos>('SHA256') | ||||||
|  | 
 | ||||||
|  | const { copy } = useCopy({ source: hashedText, text: 'Token copied to the clipboard' }) | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <style lang="scss" scoped> | ||||||
|  | </style> | ||||||
							
								
								
									
										11
									
								
								src/tools/hash-text/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/tools/hash-text/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | import { EyeOff } from '@vicons/tabler'; | ||||||
|  | import type { ITool } from '../Tool'; | ||||||
|  | 
 | ||||||
|  | export const tool: ITool = { | ||||||
|  |   name: 'Hash text', | ||||||
|  |   path: '/hash-text', | ||||||
|  |   description: 'Hash a text string using the function you need : MD5, SHA1, SHA256, SHA224, SHA512, SHA384, SHA3 or RIPEMD160', | ||||||
|  |   keywords: ['hash', 'digest', 'crypto', 'security', 'text', 'MD5', 'SHA1', 'SHA256', 'SHA224', 'SHA512', 'SHA384', 'SHA3', 'RIPEMD160'], | ||||||
|  |   component: () => import('./hash-text.vue'), | ||||||
|  |   icon: EyeOff, | ||||||
|  | }; | ||||||
| @ -2,12 +2,13 @@ import { LockOpen } from '@vicons/tabler'; | |||||||
| import type { ToolCategory } from './Tool'; | import type { ToolCategory } from './Tool'; | ||||||
| 
 | 
 | ||||||
| import { tool as tokenGenerator } from './token-generator'; | import { tool as tokenGenerator } from './token-generator'; | ||||||
|  | import { tool as hashText } from './hash-text'; | ||||||
| 
 | 
 | ||||||
| export const toolsByCategory: ToolCategory[] = [ | export const toolsByCategory: ToolCategory[] = [ | ||||||
|   { |   { | ||||||
|     name: 'Crypto', |     name: 'Crypto', | ||||||
|     icon: LockOpen, |     icon: LockOpen, | ||||||
|     components: [tokenGenerator], |     components: [tokenGenerator, hashText], | ||||||
|   }, |   }, | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user