MCPcopy Index your code
hub / github.com/LasCC/HackTools / Base64Encode

Function Base64Encode

src/components/encoding/DataEncoding.tsx:34–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34const Base64Encode = () => {
35 const [ input, setInput ] = useState( '' );
36 const [ output, setOutput ] = useState( '' );
37 const { TextArea } = Input;
38 const successBase64Copy = () => {
39 message.success( 'Your payload has been copied successfully !' );
40 };
41 const handleChange = ( _name: string ) => ( event: { target: { value: React.SetStateAction<string> } } ) => {
42 setInput( event.target.value );
43 };
44 const handleClick = ( type: string ) => {
45 let output;
46 let errorMessage;
47 switch ( type ) {
48 case "encode":
49 switch ( encMode ) {
50 case "base64":
51 output = btoa( input );
52 break;
53 case "uri":
54 try {
55 output = encodeURI( input );
56 } catch ( error ) {
57 errorMessage = "Incorrect format, please try something else.";
58 }
59 break;
60 case "hex":
61 try {
62 output = toHex( input );
63 } catch ( error ) {
64 errorMessage = "Incorrect Hex, please try something else.";
65 }
66 break;
67 }
68 break;
69 case "decode":
70 switch ( encMode ) {
71 case "base64":
72 try {
73 output = atob( input );
74 } catch ( ex ) {
75 errorMessage = "Incorrect Base64, please try something else.";
76 }
77 break;
78 case "uri":
79 try {
80 output = decodeURI( input );
81 } catch ( ex ) {
82 errorMessage = "Incorrect URI, please try something else.";
83 }
84 break;
85 case "hex":
86 try {
87 output = hex2a( input );
88 } catch ( ex ) {
89 errorMessage = "Incorrect hexadecimal, please try something else.";
90 }
91 break;

Callers

nothing calls this directly

Calls 3

handleQuoteEscaperFunction · 0.85
handleChangeFunction · 0.70
handleClickFunction · 0.70

Tested by

no test coverage detected