https://github.com/idimetrix/key-encode-decode
`key-encode-decode` is a simple Node.js package for encoding and decoding strings using a specified key with AES-256-CBC encryption.
https://github.com/idimetrix/key-encode-decode
Last synced: 6 months ago
JSON representation
`key-encode-decode` is a simple Node.js package for encoding and decoding strings using a specified key with AES-256-CBC encryption.
- Host: GitHub
- URL: https://github.com/idimetrix/key-encode-decode
- Owner: idimetrix
- License: other
- Created: 2024-09-16T22:56:31.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-09-16T22:56:57.000Z (8 months ago)
- Last Synced: 2024-11-01T15:15:48.157Z (7 months ago)
- Language: TypeScript
- Size: 60.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# key-encode-decode
`key-encode-decode` is a simple Node.js package for encoding and decoding strings using a specified key with AES-256-CBC encryption.## Installation
To install the package, use npm:
```bash
pnpm add key-encode-decodeyarn install key-encode-decode
npm install key-encode-decode
```## Usage
```typescript
import { encodeWithKey, decodeWithKey } from 'key-encode-decode';const key = 'your-encryption-key-32-characters-long'; // Ensure the key is 32 characters long
const data = 'Hello, World!';// Encode the data
const encoded = encodeWithKey(data, key);
console.log('Encoded:', encoded);// Decode the data
const decoded = decodeWithKey(encoded, key);
console.log('Decoded:', decoded);
```## encodeWithKey(decodedData: string, key: string): string
Encodes a string using the specified key. The key must be a 32-character string (256 bits).### Parameters:
### decodedData: The string to be encoded.
key: The encryption key (must be 32 characters long).
Returns:The encoded string in hexadecimal format.
## decodeWithKey(encodedData: string, key: string): string
Decodes a string using the specified key. The key must be a 32-character string (256 bits).### Parameters:
### encodedData: The string to be decoded (in hexadecimal format).
key: The encryption key (must be 32 characters long).
Returns:The decoded string.
## tsup
Bundle your TypeScript library with no config, powered by esbuild.https://tsup.egoist.dev/
## How to use this
1. install dependencies
```
# pnpm
$ pnpm install# yarn
$ yarn install# npm
$ npm install
```
2. Add your code to `src`
3. Add export statement to `src/index.ts`
4. Test build command to build `src`.
Once the command works properly, you will see `dist` folder.```zsh
# pnpm
$ pnpm run build# yarn
$ yarn run build# npm
$ npm run build
```
5. Publish your package```zsh
$ npm publish
```## test package
https://www.npmjs.com/package/key-encode-decode