-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from emiljohansson/feature/encryption
Feature/encryption
- Loading branch information
Showing
18 changed files
with
276 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { DefaultTags } from '@/ui/DefaultTags' | ||
|
||
export default function Head () { | ||
return ( | ||
<> | ||
<DefaultTags /> | ||
<title>Encrypt & Decrypt a String</title> | ||
<meta name="description" content="Encrypt & Decrypt a String" /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use client' | ||
|
||
import { useRef, useState } from 'react' | ||
|
||
import { Label } from '@radix-ui/react-label' | ||
import { AES, enc } from 'crypto-js' | ||
import Header from 'shared/Header' | ||
import Content from '@/components/Content' | ||
import Section from '@/components/Section' | ||
|
||
const Encrypt = () => { | ||
const secretRef = useRef(null) | ||
const stringRef = useRef(null) | ||
const [encryptedValue, setEncryptedValue] = useState('') | ||
|
||
function onChange () { | ||
const secret = secretRef.current.value | ||
const string = stringRef.current.value | ||
const encrypted = AES.encrypt(string, secret).toString() | ||
setEncryptedValue(encrypted) | ||
} | ||
|
||
return ( | ||
<div className="text-left"> | ||
<h2>Encrypt</h2> | ||
<div className="grid grid-cols-2-auto gap-2 items-center"> | ||
<Label htmlFor="en-secret" className="pr-3">Enter Secret</Label> | ||
<input id="en-secret" className="input w-80 pr-9" ref={secretRef} onChange={onChange} /> | ||
<Label htmlFor="en-string" className="pr-3">Enter String</Label> | ||
<input id="en-string" className="input w-80 pr-9" ref={stringRef} onChange={onChange} /> | ||
<Label htmlFor="en-result" className="pr-3">Encrypted Value</Label> | ||
<input id="en-result" className="input w-80 pr-9" readOnly value={encryptedValue} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const Decrypt = () => { | ||
const secretRef = useRef(null) | ||
const stringRef = useRef(null) | ||
const [decryptedValue, setDecryptedValue] = useState('') | ||
|
||
function onChange () { | ||
const secret = secretRef.current.value | ||
const encryptedValue = stringRef.current.value | ||
const bytes = AES.decrypt(encryptedValue, secret) | ||
setDecryptedValue(bytes.toString(enc.Utf8)) | ||
} | ||
|
||
return ( | ||
<div className="text-left"> | ||
<h2>Decrypt</h2> | ||
<div className="grid grid-cols-2-auto gap-2 items-center"> | ||
<Label htmlFor="de-secret" className="pr-3">Enter Secret</Label> | ||
<input id="de-secret" className="input w-80 pr-9" ref={secretRef} onChange={onChange} /> | ||
<Label htmlFor="de-string" className="pr-3">Enter Encrypted Value</Label> | ||
<input id="de-string" className="input w-80 pr-9" ref={stringRef} onChange={onChange} /> | ||
<Label htmlFor="de-result" className="pr-3">Decrypted Value</Label> | ||
<input id="de-result" className="input w-80 pr-9" readOnly value={decryptedValue} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const EncryptionPage = () => { | ||
return ( | ||
<Content> | ||
<Header /> | ||
<Section> | ||
<div className="grid lg:grid-cols-2 gap-8"> | ||
<Encrypt /> | ||
<Decrypt /> | ||
</div> | ||
</Section> | ||
</Content> | ||
) | ||
} | ||
|
||
export default EncryptionPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,10 @@ | ||
const name = 'Emil Johansson' | ||
export const siteTitle = 'emiljohansson.dev' | ||
import { DefaultTags } from '@/ui/DefaultTags' | ||
|
||
export default function Head () { | ||
return ( | ||
<> | ||
<DefaultTags /> | ||
<title>Welcome to emiljohansson.dev | emiljohansson.dev</title> | ||
|
||
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-touch-icon.png" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/images/logo/favicon-32x32.png" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/images/logo/favicon-16x16.png" /> | ||
<link rel="manifest" href="/images/logo/site.webmanifest" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="author" content={name} /> | ||
<meta name="description" content="Emil's development playground." /> | ||
<meta | ||
property="og:image" | ||
content={`https://og-image.vercel.app/${encodeURI( | ||
siteTitle, | ||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`} | ||
/> | ||
<meta name="og:title" content={siteTitle} /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
"paths": { | ||
"@/components/*": [ | ||
"./components/*" | ||
], | ||
"@/ui/*": [ | ||
"./ui/*" | ||
] | ||
}, | ||
"plugins": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const name = 'Emil Johansson' | ||
export const siteTitle = 'emiljohansson.dev' | ||
|
||
export function DefaultTags () { | ||
return ( | ||
<> | ||
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-touch-icon.png" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/images/logo/favicon-32x32.png" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/images/logo/favicon-16x16.png" /> | ||
<link rel="manifest" href="/images/logo/site.webmanifest" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="author" content={name} /> | ||
<meta name="description" content="Emil's development playground." /> | ||
<meta | ||
property="og:image" | ||
content={`https://og-image.vercel.app/${encodeURI( | ||
siteTitle, | ||
)}.png?theme=light&md=0&fontSize=75px&images=https%3A%2F%2Fassets.zeit.co%2Fimage%2Fupload%2Ffront%2Fassets%2Fdesign%2Fnextjs-black-logo.svg`} | ||
/> | ||
<meta name="og:title" content={siteTitle} /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
608bc68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
password-manager – ./apps/password-manager
password-manager-git-main-emiljohansson.vercel.app
pw.emiljohansson.dev
password-manager-kappa-blush.vercel.app
password-manager-emiljohansson.vercel.app
608bc68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
emiljohansson.dev – ./apps/next
emiljohansson.dev
emiljohanssondev-git-main-emiljohansson.vercel.app
emiljohanssondev-emiljohansson.vercel.app
608bc68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
games – ./apps/games
games-git-main-emiljohansson.vercel.app
games-emiljohansson.vercel.app
games.emiljohansson.dev
games-ivory.vercel.app