{"id":27135561,"url":"https://github.com/go-universal/cryptography","last_synced_at":"2025-04-10T00:09:38.012Z","repository":{"id":286567310,"uuid":"961360949","full_name":"go-universal/cryptography","owner":"go-universal","description":"🔐 Cryptography utilities for Go.","archived":false,"fork":false,"pushed_at":"2025-04-07T08:08:45.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:09:29.553Z","etag":null,"topics":["asymetric-cryptography","cryptography","golang","hashing","symetric-cryptography"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-universal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-06T11:02:26.000Z","updated_at":"2025-04-08T09:32:21.000Z","dependencies_parsed_at":"2025-04-07T08:39:50.259Z","dependency_job_id":null,"html_url":"https://github.com/go-universal/cryptography","commit_stats":null,"previous_names":["go-universal/cryptography"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-universal%2Fcryptography","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-universal%2Fcryptography/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-universal%2Fcryptography/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-universal%2Fcryptography/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-universal","download_url":"https://codeload.github.com/go-universal/cryptography/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131317,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asymetric-cryptography","cryptography","golang","hashing","symetric-cryptography"],"created_at":"2025-04-08T01:48:40.106Z","updated_at":"2025-04-10T00:09:37.992Z","avatar_url":"https://github.com/go-universal.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cryptography Library\n\n![GitHub Tag](https://img.shields.io/github/v/tag/go-universal/cryptography?sort=semver\u0026label=version)\n[![Go Reference](https://pkg.go.dev/badge/github.com/go-universal/cryptography.svg)](https://pkg.go.dev/github.com/go-universal/cryptography)\n[![License](https://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/go-universal/cryptography/blob/main/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/go-universal/cryptography)](https://goreportcard.com/report/github.com/go-universal/cryptography)\n![Contributors](https://img.shields.io/github/contributors/go-universal/cryptography)\n![Issues](https://img.shields.io/github/issues/go-universal/cryptography)\n\nThis library provides a comprehensive set of cryptographic utilities for hashing, encryption, and key management. It supports both symmetric and asymmetric cryptography, as well as various hashing algorithms.\n\n## Features\n\n- Symmetric encryption using AES-GCM.\n- Asymmetric encryption using RSA.\n- Hashing with Argon2, bcrypt, and HMAC.\n- Key generation and parsing utilities.\n\n## Installation\n\nTo use this library, add it to your Go project:\n\n```bash\ngo get github.com/go-universal/cryptography\n```\n\n## API Documentation\n\n### Symmetric Encryption\n\nCreates a new symmetric encryption driver.\n\n```go\nfunc NewSymmetric(key SimpleKey, signer HashingAlgo) Cryptography\n```\n\n```go\nkey, _ := cryptography.NewSimpleKey(cryptography.Simple32)\ndriver := cryptography.NewSymmetric(key, cryptography.SHA256)\n\ndata := []byte(\"my secret data\")\n\n// Encrypt\nencrypted, _ := driver.EncryptBase64(data)\n\n// Decrypt\ndecrypted, _ := driver.DecryptBase64(encrypted)\nfmt.Println(string(decrypted)) // Output: my secret data\n```\n\n### Asymmetric Encryption\n\nCreates a new asymmetric encryption driver with a private key.\n\n```go\nfunc NewAsymmetric(key RSAKey, signer HashingAlgo) Cryptography\n```\n\n#### `NewAsymmetricClient`\n\nCreates a new asymmetric encryption driver with a public key.\n\n```go\nfunc NewAsymmetricClient(public *rsa.PublicKey, signer HashingAlgo) Cryptography\n```\n\n```go\nkey, _ := cryptography.NewRSAKey(cryptography.RSA2048)\ndriver := cryptography.NewAsymmetric(*key, cryptography.SHA256)\n\ndata := []byte(\"my secret data\")\n\n// Encrypt\nencrypted, _ := driver.EncryptBase64(data)\n\n// Decrypt\ndecrypted, _ := driver.DecryptBase64(encrypted)\nfmt.Println(string(decrypted)) // Output: my secret data\n```\n\n### Hashing\n\nCreates a new Argon2 hasher.\n\n```go\nfunc NewArgon2Hasher(\n    saltLength SimpleLength, keyLength uint32,\n    memory uint32, iterations uint32, parallelism uint8,\n) Hasher\n```\n\nCreates a new bcrypt hasher.\n\n```go\nfunc NewBcryptHasher(cost int) Hasher\n```\n\nCreates a new HMAC hasher.\n\n```go\nfunc HMacHasher(key []byte, algo HashingAlgo) Hasher\n```\n\n```go\npassword := []byte(\"my_password\")\n\n// Argon2\nargon2Hasher := cryptography.NewArgon2Hasher(0, 0, 0, 0, 0)\nhashed, _ := argon2Hasher.Hash(password)\nvalid, _ := argon2Hasher.Validate(hashed, password)\nfmt.Println(valid) // Output: true\n\n// bcrypt\nbcryptHasher := cryptography.NewBcryptHasher(0)\nhashed, _ = bcryptHasher.Hash(password)\nvalid, _ = bcryptHasher.Validate(hashed, password)\nfmt.Println(valid) // Output: true\n```\n\n### Key Management\n\n#### Simple Key\n\nGenerates a new random key of the specified length.\n\n```go\nfunc NewSimpleKey(length SimpleLength) (SimpleKey, error)\n```\n\n#### RSA Key\n\nGenerates a new RSA private key of the specified length.\n\n```go\nfunc NewRSAKey(length RSALength) (*RSAKey, error)\n```\n\n#### Parse Private Key\n\nParses an RSA private key from PKCS#1 or PKCS#8 format.\n\n```go\nfunc ParsePrivateKey(key []byte, isPEM bool) (*RSAKey, error)\n```\n\n#### Parse Public Key\n\nParses an RSA public key from PKIX or PKCS#1 format.\n\n```go\nfunc ParsePublicKey(key []byte, isPEM bool) (*rsa.PublicKey, error)\n```\n\n```go\n// Generate a new RSA key\nrsaKey, _ := cryptography.NewRSAKey(cryptography.RSA2048)\n\n// Export and parse the private key\nprivateKeyPEM, _ := rsaKey.PrivateKeyPEM(true)\nparsedKey, _ := cryptography.ParsePrivateKey(privateKeyPEM, true)\n\n// Export and parse the public key\npublicKeyPEM, _ := rsaKey.PublicKeyPEM(true)\nparsedPublicKey, _ := cryptography.ParsePublicKey(publicKeyPEM, true)\n```\n\n## License\n\nThis project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-universal%2Fcryptography","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-universal%2Fcryptography","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-universal%2Fcryptography/lists"}