Skip to content

SecurCrypt is a Go package that provides robust encryption and decryption using AES-GCM with a secure key derivation function (PBKDF2).

License

Notifications You must be signed in to change notification settings

Mahmoud-Italy/securcrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 SecurCrypt - AES-GCM Encryption in Go

Go Reference License Go Report Card Version Go Version

SecurCrypt is a Go package that provides robust encryption and decryption using AES-GCM with a secure key derivation function (PBKDF2). It ensures high security, authenticity, and integrity of your encrypted data.

🚀 Features

  • AES-GCM Encryption (Authenticated Encryption)

  • PBKDF2 Key Derivation (Strengthens password-based encryption)

  • Random Salt & Nonce Generation (Ensures uniqueness)

  • Base64 Encoding (Safe for storage & transmission)

  • Secure and Efficient Implementation

📦 Installation

go get -u github.com/mahmoud-italy/securcrypt

🏗️ Usage

Import the package

import (
    "fmt"
    "log"
    "github.com/mahmoud-italy/securcrypt"
)

Encrypting a Message

passphrase := "SuperSecurePassword123!"
plaintext := "Hello, this is a secret message."

encryptedText, err := securcrypt.Encrypt(plaintext, passphrase)
if err != nil {
    log.Fatalf("Encryption failed: %v", err)
}
fmt.Println("Encrypted:", encryptedText)
Encrypted: brmcZrUfwt7B9cXxYl57rbQ1bnS3oArxfaAFUlFzL1jv2kI7xX9EIEK5owkcDJNcPNpfN/WNomg6nKjXhqMuWxmqXuC4Z6Fb9vDSyA==

Decrypting a Message

decryptedText, err := securcrypt.Decrypt(encryptedText, passphrase)
if err != nil {
    log.Fatalf("Decryption failed: %v", err)
}
fmt.Println("Decrypted:", decryptedText)
Decrypted: Hello, this is a secret message.

🛠️ Running Tests

We have included test cases to ensure the correctness of the encryption and decryption logic.

Run tests using:

go test

Example Test Case (Inside securcrypt_test.go)

package securcrypt_test

import (
    "testing"

    "github.com/mahmoud-italy/securcrypt"
)

func TestEncryptionDecryption(t *testing.T) {
    passphrase := "TestPassphrase"
    plaintext := "SecretData"

    encrypted, err := securcrypt.Encrypt(plaintext, passphrase)
    if err != nil {
        t.Fatalf("Encryption failed: %v", err)
    }

    decrypted, err := securcrypt.Decrypt(encrypted, passphrase)
    if err != nil {
        t.Fatalf("Decryption failed: %v", err)
    }

    if decrypted != plaintext {
        t.Fatalf("Expected %s but got %s", plaintext, decrypted)
    }
}

🔖 License

The MIT License (MIT). Please see License File for more information.

🤝 Contributing

Feel free to contribute by submitting issues or pull requests.

About

SecurCrypt is a Go package that provides robust encryption and decryption using AES-GCM with a secure key derivation function (PBKDF2).

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages