https://github.com/fckveza/cryptoutil
Cryptoutil
https://github.com/fckveza/cryptoutil
aes-encryption aes-gcm bytecode cryptography encryption-decryption hashing
Last synced: 5 months ago
JSON representation
Cryptoutil
- Host: GitHub
- URL: https://github.com/fckveza/cryptoutil
- Owner: fckveza
- License: mit
- Created: 2023-11-03T12:17:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-06T07:42:00.000Z (9 months ago)
- Last Synced: 2025-10-06T09:39:56.945Z (9 months ago)
- Topics: aes-encryption, aes-gcm, bytecode, cryptography, encryption-decryption, hashing
- Language: Go
- Homepage: https://vhtear.com
- Size: 14.6 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cryptoutil
Cryptoutil is a Go (Golang) toolkit that provides various cryptographic and data manipulation functions. This package is designed to assist developers in implementing cryptography, encryption, decryption, and data manipulation easily and efficiently.
With Cryptoutil, you can quickly integrate powerful cryptographic functions into your projects and efficiently manipulate data. This package is suitable for the development of applications that require data security, such as financial applications, sensitive data processing, and many others.
## Key Features
- AES-GCM encryption and decryption functions.
- Calculation of checksums and data transformation using hashing.
- Data processing in byte and hexadecimal formats.
- And many other features.
## Installation
You can easily install this package using the following command:
```shell
go get github.com/fckveza/Cryptoutil
```
#### Extended usage
```go
package main
import (
"fmt"
"github.com/fckveza/Cryptoutil"
)
func main() {
// Example of using GetSHA256Sum
sha256Sum := Cryptoutil.GetSHA256Sum("Hello, World!")
fmt.Printf("SHA-256 Sum: %x\n", sha256Sum)
// Example of using GenerateSharedSecret
privateKey := []byte("private_key")
publicKey := []byte("public_key")
sharedSecret, err := Cryptoutil.GenerateSharedSecret(privateKey, publicKey)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Printf("Shared Secret: %x\n", sharedSecret)
}
// Example of using GenerateAAD
aad := Cryptoutil.GenerateAAD("example", "data", 42, 13, 7, 99)
fmt.Printf("AAD: %x\n", aad)
// Example of using DecryptWithAESGCM
gcmKey := []byte("secret_key")
nonce := []byte("unique_nonce")
ciphertext := []byte("encrypted_data")
message, err := Cryptoutil.DecryptWithAESGCM(gcmKey, nonce, ciphertext, aad)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Printf("Decrypted Message: %s\n", message)
}
// Example of using EncryptWithAESGCM
dataToEncrypt := []byte("sensitive_data")
ciphertext, err := Cryptoutil.EncryptWithAESGCM(dataToEncrypt, gcmKey, nonce, aad)
if err is not nil {
fmt.Println("Error:", err)
} else {
fmt.Printf("Encrypted Data: %x\n", ciphertext)
}
// Example of using EncHeaders
headers := map[string]string{
"Content-Type": "application/json",
"Authorization": "Bearer token",
}
encodedHeaders := Cryptoutil.EncHeaders(headers)
fmt.Printf("Encoded Headers: %x\n", encodedHeaders)
// Example of using Pad
dataToPad := []byte("data_to_pad")
paddedData := Cryptoutil.Pad(dataToPad, 16)
fmt.Printf("Padded Data: %x\n", paddedData)
// Example of using Unpad
unpaddedData, err := Cryptoutil.Unpad(paddedData)
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Printf("Unpadded Data: %x\n", unpaddedData)
}
// Example of using CalculateChecksumAndTransform
key := []byte("encryption_key")
dataToTransform := []byte("data_to_transform")
transformedData := Cryptoutil.CalculateChecksumAndTransform(key, dataToTransform)
fmt.Printf("Transformed Data: %x\n", transformedData)
// Example of using ParseHexToSlice
hexString := "48656c6c6f2c20576f726c6421"
hexData := Cryptoutil.ParseHexToSlice(hexString)
fmt.Printf("Hex Data: %x\n", hexData)
// Example of using Xor
dataToXor := []byte("data_to_xor")
xoredData := Cryptoutil.Xor(dataToXor)
fmt.Printf("Xored Data: %x\n", xoredData)
// Example of using CombineBytesToResult
dataToCombine := []byte{0x12, 0x34}
result := Cryptoutil.CombineBytesToResult(dataToCombine, 0)
fmt printf("Combined Result: %x\n", result)
// Example of using AccessAndTransformElement
dataToAccess := []byte{0xFF, 0x80}
element := Cryptoutil.AccessAndTransformElement(dataToAccess, 0)
fmt.Printf("Accessed and Transformed Element: %x\n", element)
}
```