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.
-
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
go get -u github.com/mahmoud-italy/securcrypt
import (
"fmt"
"log"
"github.com/mahmoud-italy/securcrypt"
)
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==
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.
We have included test cases to ensure the correctness of the encryption and decryption logic.
go test
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)
}
}
The MIT License (MIT). Please see License File for more information.
Feel free to contribute by submitting issues or pull requests.