MCPcopy Create free account
hub / github.com/LasCC/HackTools / HashEncode

Function HashEncode

src/components/encoding/Hashing.tsx:18–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16} );
17
18const HashEncode = () => {
19 const [ input, setInput ] = useState<string>( '' );
20 const [ _, setHashType ] = useState( '0' );
21 const [ hashname, setHashname ] = useState( 'MD5' );
22 const [ output, setOutput ] = useState( '' );
23 const handleClick = ( type: { key: React.SetStateAction<string | any> } ) => {
24 setHashType( type.key );
25 resolvehashname( type.key );
26 };
27 const handleEncode = ( hashtype: string ) => {
28 let output: string;
29 switch ( hashtype ) {
30 case 'MD5':
31 output = MD5( input, undefined ).toString();
32 break;
33 case 'SHA1':
34 output = SHA1( input, undefined ).toString();
35 break;
36 case 'SHA256':
37 output = SHA256( input, undefined ).toString();
38 break;
39 case 'SHA512':
40 output = SHA512( input, undefined ).toString();
41 break;
42 case 'SM3':
43 output = Sm3( input );
44 break;
45 default:
46 // If the hashtype is not recognized, return an empty string
47 output = '';
48 }
49 setOutput( output );
50 };
51 const successInfoHashing = () => {
52 message.success( 'Your hash has been copied successfully !' );
53 };
54 const resolvehashname = ( hashindex: string ): 'Choose the Hash type' => {
55 switch ( hashindex ) {
56 case '0':
57 setHashname( 'MD5' );
58 break;
59 case '1':
60 setHashname( 'SHA1' );
61 break;
62 case '2':
63 setHashname( 'SHA256' );
64 break;
65 case '3':
66 setHashname( 'SHA512' );
67 break;
68 case '4':
69 setHashname( 'SM3' );
70 break;
71 }
72 return 'Choose the Hash type';
73 };
74
75 const menu = (

Callers

nothing calls this directly

Calls 2

handleEncodeFunction · 0.85
handleChangeFunction · 0.70

Tested by

no test coverage detected