Skip to content

Commit 127b78d

Browse files
committed
Add page for encrypting with public key
1 parent 5e88b6d commit 127b78d

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

src/app/(authed)/encrypt/action.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

src/app/(authed)/encrypt/page.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}

0 commit comments

Comments
 (0)