{"id":25238007,"url":"https://github.com/vspaz/rsa-encrypt-decrypt-golang","last_synced_at":"2025-10-26T12:30:52.974Z","repository":{"id":144339054,"uuid":"293128443","full_name":"vspaz/rsa-encrypt-decrypt-golang","owner":"vspaz","description":"a Go library to encrypt/decrypt data with RSA public/private key pair and do base85/base64 encoding/decoding.","archived":false,"fork":false,"pushed_at":"2024-03-11T20:02:36.000Z","size":72,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-11T21:25:30.959Z","etag":null,"topics":["ascii85","base64","base64-decoding","base64-encoding","base85","crypto","decrypt","decryption","encrypt","go","golang","rsa","x509"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vspaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2020-09-05T18:01:18.000Z","updated_at":"2024-01-20T21:09:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"277fb8ea-38c9-4e59-b120-939b5f118e4e","html_url":"https://github.com/vspaz/rsa-encrypt-decrypt-golang","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Frsa-encrypt-decrypt-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Frsa-encrypt-decrypt-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Frsa-encrypt-decrypt-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vspaz%2Frsa-encrypt-decrypt-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vspaz","download_url":"https://codeload.github.com/vspaz/rsa-encrypt-decrypt-golang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238324678,"owners_count":19453140,"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":["ascii85","base64","base64-decoding","base64-encoding","base85","crypto","decrypt","decryption","encrypt","go","golang","rsa","x509"],"created_at":"2025-02-11T16:03:08.051Z","updated_at":"2025-10-26T12:30:52.667Z","avatar_url":"https://github.com/vspaz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rsa-encrypt-decrypt-golang\n\na small library to encrypt/decrypt data with RSA public/private key pair and \nbase64/85 encoding/decoding capabilities.\n\nyou can generate your own key pair as:\n\n### Generating test public/private RSA key-pair.\n\n```shell\nopenssl genrsa -out private.pem 2048\nopenssl rsa -in private.pem -out public.pem -pubout -outform PEM\n```\n\n### Usage example\n\n```go\npackage main\n\nconst (\n\ttestPrivateKey = `-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAxGDcSAjiHKP9v2ITR+BjQmt9Tx2zW08ZyrjOxPew+Gxl2m5z\nJyoP8sicZV81BeMNFkMg6q7sMtRXHhX1nFiTql5HBIqhZohYlN3LIXK2bdPWpDtt\nrOFXfsSbZ4Wqy3XhXBhiPNn3kkkRv1N5L/IYcdrxwqaqvTlJzOeQnDsd3+AmkYst\nuD4rgElOFkcUawtF7lKIYYFi42cYkJo51UD460mYieBezP6dZhFZB56pZ2rV8cQU\nNrUQy2llpj+PxX/yhGnYI88ij0FST0gI2l4UsjtwXVB1Y2Sx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BcBaiXtcCRYV3bEHHCnTHW9n3+mwOaVs3uLLQynVRzBHT8zGudbyvFZwk9A+aZ\n5xENAoGBALO842ymiZmFYiv9CIdfBGFokbokQMci+4cJm4wWzxEiDjAzSglRHAei\n/+oGBiPm8mKmx/dcU408x4PK76JlfduuoXuzE9jEmx46kwU4jGDS1GZYkwjGVPY8\n8UmZ7fFkjNFJH0Rh5y+tmoFyou3FsWzL2lpd1mIryAH2LR3PGE/t\n-----END RSA PRIVATE KEY-----\n`\n\ttestPublicKey = `-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxGDcSAjiHKP9v2ITR+Bj\nQmt9Tx2zW08ZyrjOxPew+Gxl2m5zJyoP8sicZV81BeMNFkMg6q7sMtRXHhX1nFiT\nql5HBIqhZohYlN3LIXK2bdPWpDttrOFXfsSbZ4Wqy3XhXBhiPNn3kkkRv1N5L/IY\ncdrxwqaqvTlJzOeQnDsd3+AmkYstuD4rgElOFkcUawtF7lKIYYFi42cYkJo51UD4\n60mYieBezP6dZhFZB56pZ2rV8cQUNrUQy2llpj+PxX/yhGnYI88ij0FST0gI2l4U\nsjtwXVB1Y2SxqrhNMdBU7W6ZA8WUQQidr4MBxEFoujsLjaCl8LMsbEpAAilKezwu\nbQIDAQAB\n-----END PUBLIC KEY-----\n`\n)\n```\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib\"\n)\n\nfunc rsaEncryptDecrypt() {\n\t// example_1: Encrypt/Decrypt with RSA\n\texpectedText := \"some expectedText goes here\"\n\tencoder := cryptolib.NewEncoder(testPublicKey)\n\trsaEncryptedText := encoder.Encrypt(expectedText)\n\n\tdecoder := cryptolib.NewDecoder(testPrivateKey)\n\trsaDecryptedText := decoder.Decrypt(rsaEncryptedText)\n\n\tif expectedText != rsaDecryptedText {\n\t\tlog.Fatalln(\"failed to decrypt\")\n\t}\n}\n\n```\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib\"\n)\n\nfunc rsaEncryptDecryptAndBase85Encode() {\n\texpectedText := \"some expectedText goes here\"\n\n\t// encoding example\n\tencoder := cryptolib.NewEncoder(testPublicKey)\n\trsaEncodedText := encoder.Encrypt(text)\n\tbase85EncodedText := encoder.ToBase85(rsaEncodedText)\n\tlog.Println(base85EncodedText)\n\n\t// decoding example\n\tdecoder := cryptolib.NewDecoder(testPrivateKey)\n\tbase85decodedText := decoder.FromBase85(base85EncodedText)\n\trsaDecodedText := decoder.Decrypt(base85decodedText)\n\tlog.Println(rsaDecodedText) // -\u003e  \"some text data\"\n\tif rsaDecodedText != expectedText {\n\t\tlog.Fatalln(\"failed to decrypt\")\n\t}\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib\"\n\t\"log\"\n)\n\nfunc rsaEncryptDecryptAndBase64Encode() {\n\texpectedText := \"some expectedText goes here\"\n\n\t// encoding example\n\tencoder := cryptolib.NewEncoder(testPublicKey)\n\trsaEncodedText := encoder.Encrypt(expectedText)\n\tbase64EncodedText := encoder.ToBase64(rsaEncodedText)\n\tlog.Println(base64EncodedText)\n\n\t// decoding example\n\tdecoder := cryptolib.NewDecoder(testPrivateKey)\n\tbase64decodedText := decoder.FromBase64(base64EncodedText)\n\trsaDecodedText := decoder.Decrypt(base64decodedText)\n\tlog.Println(rsaDecodedText) // -\u003e  \"some text data\"\n\tif rsaDecodedText != expectedText {\n\t\tlog.Fatalln(\"failed to decrypt\")\n\t}\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib\"\n\t\"log\"\n)\n\nfunc encodeDecodeWithBase85() {\n\texpectedText := \"some expectedText goes here\"\n\tencodedText := cryptolib.Encoder{}.ToBase85([]byte(expectedText))\n\tactualText := string(cryptolib.Decoder{}.FromBase85(encodedText))\n\tif actualText !=  expectedText {\n\t\tlog.Fatalln(\"failed to decode\")\n    }\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"github.com/vspaz/rsa-encrypt-decrypt-golang/pkg/cryptolib\"\n\t\"log\"\n)\n\nfunc encodeDecodeWithBase64() {\n\texpectedText := \"some expectedText goes here\"\n\tencodedText := cryptolib.Encoder{}.ToBase64([]byte(expectedText))\n\tactualText := string(cryptolib.Decoder{}.FromBase64(encodedText))\n\tif actualText !=  expectedText {\n\t\tlog.Fatalln(\"failed to decode\")\n    }\n}\n```\n\n**NOTE**: please refer to: \n* [rsa-encrypt-decrypt-rust](https://github.com/vspaz/rsa-encrypt-decrypt-rust) for the Rust lib\n* [rsa-encrypt-decrypt-python](https://github.com/vspaz/rsa-encrypt-decrypt-python) for the Python lib\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspaz%2Frsa-encrypt-decrypt-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvspaz%2Frsa-encrypt-decrypt-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvspaz%2Frsa-encrypt-decrypt-golang/lists"}