A simple, semantic and developer-friendly crypto package for golang
A simple, semantic and developer-friendly crypto package for golang
Dongle is a simple, semantic and developer-friendly golang crypto package with 100% unit test coverage,has been included by awesome-go, and has won the gitee 2024 Most Valuable Project (GVP) and gitcode 2024 Open Source Star Project (G-Star) awards
go version >= 1.23
// Via github
go get -u github.com/dromara/dongle
// Via gitee
go get -u gitee.com/dromara/dongle
// Via gitcode
go get -u gitcode.com/dromara/dongle
Dongle was donated to the dromara organization, the repository URL has changed. If
the previous repository used was golang-module/dongle, please replace the original repository with the new repository
in go.mod, or execute the following command:
go mod edit -replace github.com/golang-module/dongle = github.com/dromara/dongle
Encode&Decode(using Base64 as an example)
import (
"github.com/dromara/dongle"
)
dongle.Encode.FromString("hello world").ByBase64().ToString() // aGVsbG8gd29ybGQ=
dongle.Decode.FromString("aGVsbG8gd29ybGQ=").ByBase64().ToString() // hello world
Hash Algorithm(using Md5 as an example)
import (
"github.com/dromara/dongle"
)
dongle.Hash.FromString("hello world").ByMd5().ToHexString() // 5eb63bbbe01eeed093cb22bb8f5acdc3
dongle.Hash.FromString("hello world").ByMd5().ToBase64String() // XrY7u+Ae7tCTyyK7j1rNww==
Hmac Algorithm(using Md5 as an example)
import (
"github.com/dromara/dongle"
)
dongle.Hash.FromString("hello world").WithKey([]byte("dongle")).ByMd5().ToHexString() // 4790626a275f776956386e5a3ea7b726
dongle.Hash.FromString("hello world").WithKey([]byte("dongle")).ByMd5().ToBase64String() // R5Biaidfd2lWOG5aPqe3Jg==
Symmetric Encryption&Decryption(using AES as an example)
…
Asymmetric Encryption&Decryption(using RSA as an example)
…
Digital Signature&Verification(using RSA as an example)
…
For more usage examples, please refer to official document, and visit Playground for online tools.
Thanks to all the following who contributed to dongle:
Dongle is a non-commercial open source project. If you want to support dongle, you can buy a cup of coffee for developer.
Dongle has obtained a free JetBrains open source license, and we would like to express our thanks here.
Dongle is licensed under the MIT License, see the LICENSE file for details.
No open issues yet, or sync has not completed.