feat(string coder) add some algorithms

This commit is contained in:
lumither committed 2024-10-15 21:12:36 -07:00
1 parent efdea9872f
commit 57a0b66b84
3 files changed
+26 -32

No files matched your search

+10 -32
View File
@@ -1,36 +1,14 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). # LMTLab
## Getting Started Source code of LMTLab
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
``` ```
# dev
npm i
npm run dev
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. # release
npm i
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. npm build
# static export avliable at /out
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. ```
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
+15
View File
@@ -1,4 +1,7 @@
import { enc, MD5, SHA1, SHA256, SHA512 } from 'crypto-js'; import { enc, MD5, SHA1, SHA256, SHA512 } from 'crypto-js';
import basex from 'base-x';
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
export const hashAlgorithms = { export const hashAlgorithms = {
'SHA-1': (input: string) => { 'SHA-1': (input: string) => {
@@ -16,6 +19,9 @@ export const hashAlgorithms = {
}; };
export const encodeAlgorithms = { export const encodeAlgorithms = {
'Base58': (input: string) => {
return basex(BASE58).encode(Buffer.from(input));
},
'Base64': (input: string) => { 'Base64': (input: string) => {
const wordArray = enc.Utf8.parse(input); const wordArray = enc.Utf8.parse(input);
return enc.Base64.stringify(wordArray); return enc.Base64.stringify(wordArray);
@@ -25,10 +31,16 @@ export const encodeAlgorithms = {
}, },
'URI Component': (input: string) => { 'URI Component': (input: string) => {
return encodeURIComponent(input).toString(); return encodeURIComponent(input).toString();
},
'Hex': (input: string) => {
return enc.Hex.stringify(enc.Utf8.parse(input));
} }
}; };
export const decodeAlgorithms = { export const decodeAlgorithms = {
'Base58': (input: string) => {
return Buffer.from(basex(BASE58).decode(input)).toString();
},
'Base64': (input: string) => { 'Base64': (input: string) => {
return enc.Base64.parse(input).toString(enc.Utf8); return enc.Base64.parse(input).toString(enc.Utf8);
}, },
@@ -37,6 +49,9 @@ export const decodeAlgorithms = {
}, },
'URI Component': (input: string) => { 'URI Component': (input: string) => {
return decodeURIComponent(input).toString(); return decodeURIComponent(input).toString();
},
'Hex': (input: string) => {
return enc.Hex.parse(input).toString(enc.Utf8);
} }
}; };
+1
View File
@@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@monaco-editor/react": "^4.6.0", "@monaco-editor/react": "^4.6.0",
"@nextui-org/react": "^2.4.8", "@nextui-org/react": "^2.4.8",
"base-x": "^5.0.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"framer-motion": "^11.11.0", "framer-motion": "^11.11.0",
"next": "14.2.14", "next": "14.2.14",