Logo

dev-resources.site

for different kinds of informations.

Day ??? of learning go. Building cli apps

Published at
8/16/2024
Categories
go
cli
cobra
cryptography
Author
xtasy
Categories
4 categories in total
go
open
cli
open
cobra
open
cryptography
open
Author
5 person written this
xtasy
open
Day ??? of learning go. Building cli apps

Why cli??

I have always had a preference for command line interface (CLI) and terminal user interface (TUI) tools over their graphical user interface (GUI) counterparts. This project, aptly named "Phraser" (no apologies for the poor naming), is a command line application designed to manage wallet seed phrases for crypto wallets. I developed this application to create a more convenient way to manage the seed phrases for my crypto wallets.
It creates a directory and stores the phrases in encrypted JSON files. You can then move the JSON files and store them anywhere you want.

Why go?

To enhance my skills, I chose to rewrite a project I had previously written in Python using Go. Unlike the Python version, which requires a multitude of dependencies to be installed, the Go version can be compiled into a single binary, making it more portable and less cumbersome. Additionally, Go is known for its blazing speed(I couldn't resist:))

Tool used

  • Go v1.22.5(of course)
  • Cobra-cli

Installation

You can find a precompiled binary on the releases page of the GitHub repository(link at end of article).

Manual Installation

If you prefer, you can clone the repository and install the dependencies to test it out.
The instructions are in the Readme in the GitHub repository, but I will still highlight them here.

Usage

Phraser is easy to use with a set of straightforward commands. Here's a basic overview:

   phraser [command] [flags]
Enter fullscreen mode Exit fullscreen mode

Commands

  • completion: Generate the autocompletion script for the specified shell.
  • create: Creates a wallet in your store.
  • gendoc: Generate Markdown documentation for all commands.
  • get: Retrieves data stored in a wallet.
  • init: Initializes a store.

Options

  -a, --amount int      amount of phrases to be inputted
  -h, --help            help for phraser
  -s, --store string    name of the store to access
  -t, --toggle          Help message for toggle
  -w, --wallet string   name of the wallet to be created
Enter fullscreen mode Exit fullscreen mode

Examples

  1. Initialize a new store:
   phraser init --store myStore
Enter fullscreen mode Exit fullscreen mode
  1. Create a new wallet:
   phraser create --store myStore --wallet myWallet --amount 12
Enter fullscreen mode Exit fullscreen mode
  1. Retrieve a wallet's seed phrase:
   phraser get --store --wallet myWallet
Enter fullscreen mode Exit fullscreen mode

Conclusion

This project taught me a lot about Go-like encryption/decryption, file handling, and also the cobra-cli for building CLI apps. Any feedback and corrections are appreciated.
The source code can be found here

cryptography Article's
30 articles in total
Favicon
How to truncate CBC ciphertext
Favicon
Bitflip Attack on CBC: Change of the Ciphertext
Favicon
Introducing Inline Cryptography Toolkit: Simplify Encryption, Decryption, and Hashing in VS Code ๐Ÿš€
Favicon
olssv dvysk!
Favicon
Bitflip Attack on CBC: Change of the IV
Favicon
Exploring Quantum Computing: The Next Frontier in Technology (2025)
Favicon
Como Habilitar o Provedor Legado no OpenSSL 3.x
Favicon
VB .Net: Secure Password
Favicon
C#: Secure Password
Favicon
Enhancing Data Security with MongoDB: A Dive into Cryptography and CSFLE at Ovianta
Favicon
What is Post-Quantum Cryptography (PQC) Migration and How to Secure Data Against Quantum Threats
Favicon
"Behind the Code: How Dark Web Drug Marketplaces Operate and the Developers Who Build Them"
Favicon
The Ultimate Guide to Choosing the Right Cryptography Algorithm for Your Project
Favicon
Lithe Crypt: Simplifying Encryption in PHP Applications
Favicon
Addressing The Threat of Deepfakes With Authentic Images
Favicon
Camouflage-Shield: An Image Encryption Application.
Favicon
Comparing Decentralized Identifiers(DID) Methods
Favicon
Decentralized Identity Simplified: How to Resolve DIDs Effectively
Favicon
Key Management for DIDs in Web5: A Beginnerโ€™s Guide
Favicon
Key Management for DIDs: A Beginner's Journey
Favicon
Understanding Web5 and Its Potential
Favicon
Cryptography in Networking
Favicon
Medium article to explore Post Quantum Cryptography and algorithms comparison
Favicon
Day ??? of learning go. Building cli apps
Favicon
Building Secure and Scalable Blockchain Applications
Favicon
Introduction to Cryptography for Beginners
Favicon
GnuPG and Digital Signatures
Favicon
Cryptography Concepts Simplified
Favicon
The Hitchhikerโ€™s Guide to Building an Encrypted Filesystem in Rust
Favicon
Cryptography #0 - Essential Concepts

Featured ones: