Skip to content

Documentation

Wesley Yan Soares Brehmer edited this page Sep 20, 2023 · 4 revisions

W7DTH Encryption Library

W7DTH is an encryption library for Go, designed to be easy, fast, lightweight, and effective.

Installation

You can use “go get” to install W7DTH in your Go project. Make sure you already have a module (go mod). You can download it using the command:

go get -u github.com/simplyYan/W7DTH

Key Generation

The Key function generates a new key or uses an existing one. If “generate” is passed as an argument, a new key is generated. Otherwise, the function expects a hexadecimal string to be passed as the key.

w := w7.New()
key, err := w.Key("generate") // Generates a new key
// OR
key, err := w.Key("existing_hexadecimal_key") // Uses an existing key

Encryption

The Encrypt function encrypts a string using the key generated or provided in the Key function. It returns the encrypted string.

data := "Hello world"
encryptedData, err := w.Encrypt(data)

Decryption

The Decrypt function decrypts a string using the key generated or provided in the Key function. It returns the decrypted string.

decryptedData, err := w.Decrypt(encryptedData)

Error Handling

All functions return an error object as the second return value. Always check this error object before proceeding.

key, err := w.Key("generate")
if err != nil {
    log.Fatal(err)
}

License

W7DHT is licensed under BSD-Clause 3 and is open-source.

Contribution

As W7DTH is completely open-source, you can contribute by adding, improving, or correcting features.

Clone this wiki locally