File tree Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use server'
2+
3+ import { encryptionService } from '@/composition'
4+
5+ export async function encrypt ( text : string ) : Promise < string > {
6+ return encryptionService . encrypt ( text )
7+ }
Original file line number Diff line number Diff line change 1+ import { Box , Stack } from "@mui/material"
2+ import SecondarySplitHeader from "@/features/sidebar/view/SecondarySplitHeader"
3+
4+ export default function Page ( { children } : { children : React . ReactNode } ) {
5+ return (
6+ < Stack sx = { { height : "100%" } } >
7+ < SecondarySplitHeader />
8+ < Box
9+ sx = { {
10+ flexGrow : 1 ,
11+ overflowY : "auto" ,
12+ paddingLeft : 2 ,
13+ paddingRight : 2
14+ } }
15+ >
16+ { children }
17+ </ Box >
18+ </ Stack >
19+ )
20+ }
Original file line number Diff line number Diff line change 1+ 'use client'
2+
3+ import { useState } from 'react'
4+ import { encrypt } from './action'
5+ import { Box , Button , TextareaAutosize , Typography } from '@mui/material'
6+
7+ export default function EncryptPage ( ) {
8+ const [ inputText , setInputText ] = useState ( '' )
9+ const [ encryptedText , setEncryptedText ] = useState ( '' )
10+
11+ const handleSubmit = async ( event : React . FormEvent ) => {
12+ event . preventDefault ( )
13+ const encrypted = await encrypt ( inputText )
14+ setEncryptedText ( encrypted )
15+ }
16+
17+ return (
18+ < Box
19+ display = "flex"
20+ alignItems = "center"
21+ justifyContent = "center"
22+ flexDirection = "column"
23+ height = { 1 }
24+ width = { 1 }
25+ gap = { 6 }
26+ >
27+ < Typography variant = "h4" >
28+ Encrypt text for remote config
29+ </ Typography >
30+ < Typography variant = "body1" >
31+ Use this to encrypt values to be used in the configuration file.< br />
32+ The input text is encrypted using the public key of the server.
33+ </ Typography >
34+ < form onSubmit = { handleSubmit } >
35+ < TextareaAutosize
36+ value = { inputText }
37+ onChange = { ( e ) => setInputText ( e . target . value ) }
38+ cols = { 50 }
39+ minRows = { 10 }
40+ />
41+ < br />
42+ < Button type = "submit" variant = "outlined"
43+ color = "primary"
44+ size = "large"
45+ sx = { { height : 56 , width : 1 } }
46+ > Encrypt</ Button >
47+ </ form >
48+ { encryptedText && (
49+ < textarea readOnly value = { encryptedText } rows = { 10 } cols = { 50 } />
50+ ) }
51+ </ Box >
52+ )
53+ }
You can’t perform that action at this time.
0 commit comments