A versatile tool for converting data between various base encodings, including Base64, Base32, Base58, and more. Available as a command-line tool and a web application, it empowers users to quickly encode, decode, or convert data seamlessly.
Note
The main functionality of this tool is now stable and fully operational. However, it is still in active development, and additional features and updates may be added in the future. Please expect occasional changes as development continues.
- π Seamless Conversion: Convert between numeral systems and base encodings (e.g., Base64 to Base32, Base58 to Base64).
- π€ String Encoding: Effortlessly transform strings into base encodings (e.g., text to Base64).
- 𧩠Decoding Made Easy: Decode base encodings back into readable text (e.g., Base64 to plain text).
- β‘ Intuitive Interface: Simple and user-friendly command-line prompts for quick and hassle-free usage.
- π High Performance: Lightweight, fast, and optimized for efficiency.
- π Versatile Utility: Perfect for data transformations, encoding workflows, and cryptographic tasks.
- πΎ Persistent History: The conversion history is saved in a JSON file, allowing you to revisit past conversions at any time.
To install this package, follow these steps:
-
Clone the repository:
First, clone the repository to your local machine to create a copy of it:git clone https://github.com/anonymByte-404/base-string-converter.git
-
Navigate to the project directory:
After cloning, move into the project directory where all the files are located:cd base-string-converter
-
Install dependencies using
npm
:
Install the required dependencies for the project by running:npm install
This will install all the necessary libraries and packages specified in the
package.json
file. -
Run the application:
Once the dependencies are installed, start the application using the following command:npm start
This will launch the application, and you should be able to use it as intended.
-
Select the type of conversion:
Choose the type of conversion you want to perform (e.g., String, Base). -
Choose the target base:
Select the target numeral system for your conversion (e.g., Base64, Base32, etc.). -
Input the string to convert:
Provide the string or data you wish to convert into the selected base or encoding. -
View the conversion output:
Check the conversion result and decide whether to proceed with further actions, such as repeating the conversion or returning to the main menu.
Below is an illustrative example of how you could use this tool programmatically in a Node.js application:
import inquirer from 'inquirer'
import chalk from 'chalk'
// Type for the answers in prompts
interface Answers {
conversionType: string
selectedBase?: string
}
// Base choices for conversion
const baseChoices: string[] = Array.from({ length: 64 }, (_, i) => `Base ${i + 1}`)
/**
* Handles errors by logging the error message to the console.
*
* @param {unknown} error - The error to handle.
* @param {string} context - The context in which the error occurred.
*/
const handleError = (error: unknown, context: string): void => {
const errorMessage = error instanceof Error ? error.message : String(error)
console.error(chalk.red(`${context}: ${errorMessage}`))
}
/**
* Logs and displays a success message when a conversion type is selected.
*
* @param {string} conversionType - The conversion type selected by the user.
*/
const logConversionSelection = (conversionType: string): void => {
console.log(chalk.green(`Selected Conversion: ${conversionType}`))
}
/**
* Main prompt logic to allow the user to choose the type of conversion.
*
* @returns {Promise<void>} - A promise that resolves when the conversion type is selected and handled.
*/
const mainPrompt = async (): Promise<void> => {
try {
const answers = await inquirer.prompt<Answers>([
{
type: 'list',
name: 'conversionType',
message: 'Select the type of conversion you want to perform:',
choices: ['String Conversion', 'Base Conversion'],
},
])
logConversionSelection(answers.conversionType)
if (answers.conversionType === 'String Conversion') {
// Placeholder function for string conversion logic
return stringConverter()
}
return await baseConversionPrompt()
} catch (error: unknown) {
handleError(error, 'An error occurred during the initial prompt')
}
}
/**
* Prompts the user to choose the target base for conversion.
*
* @returns {Promise<void>} - A promise that resolves when the base conversion is selected.
*/
const baseConversionPrompt = async (): Promise<void> => {
try {
const { selectedBase } = await inquirer.prompt<Answers>([
{
type: 'list',
name: 'selectedBase',
message: 'Choose the target base for conversion:',
choices: baseChoices,
},
])
console.log(chalk.yellow(`Selected Base: ${selectedBase}`))
if (selectedBase === 'Base 2') {
// Placeholder function for binary conversion logic
return binaryConverter()
}
console.log(chalk.red(`Conversions for ${selectedBase} are currently not supported.`))
} catch (error: unknown) {
handleError(error, 'An error occurred during base selection')
}
}
/**
* Handles the logic for string conversion (this is a placeholder for your conversion logic).
*
* @returns {Promise<void>} - A promise that resolves when the string conversion is done.
*/
const stringConverter = async (): Promise<void> => {
console.log(chalk.brightBlue('String Conversion Selected'))
// Placeholder: Your string conversion logic goes here
console.log(chalk.brightCyan('Implement string conversion logic here'))
}
/**
* Handles the logic for binary conversion (this is a placeholder for your conversion logic).
*
* @returns {Promise<void>} - A promise that resolves when the binary conversion is done.
*/
const binaryConverter = async (): Promise<void> => {
console.log(chalk.brightBlue('Binary Conversion Selected'))
// Placeholder: Your binary conversion logic goes here
console.log(chalk.brightCyan('Implement binary conversion logic here'))
}
/**
* Starts the application by prompting the user for the type of conversion.
*/
mainPrompt()
Note
This is not the actual code, but an illustration designed to demonstrate how the CLI tool operates. It serves as an example to show the general behavior and flow of the tool, rather than the complete or exact implementation.
Contributions are welcome! Here's how you can help:
-
Fork the repository.
Go to the repository page on GitHub and click the"Fork"
button to create your own copy. -
Clone your Fork
After forking the repository,clone
it to your local machine:git clone https://github.com/anonymByte-404/base-string-converter.git
-
Create a new branch for your feature or bug fix:
Create a newbranch
so you can work on your changes without affecting the main branch:git checkout -b feature/your-feature-name
-
Make your changes and commit:
After making your changes,commit
them with a meaningful message:git commit -m "Add your commit message here"
-
Push to your fork:
Push to yourfork
:git push origin feature/your-feature-name
-
Open a pull request on the main repository.
Go to the original repository on GitHub (https://github.com/anonymByte-404/base-string-converter) and open apull request
with your changes.
This project is licensed under the AGPL-3.0 License. See the LICENSE file for more details.