{"id":18162819,"url":"https://github.com/zunda-pixel/selene","last_synced_at":"2025-07-06T18:12:43.486Z","repository":{"id":190881705,"uuid":"637619666","full_name":"zunda-pixel/selene","owner":"zunda-pixel","description":"Generate Code for Secure Value from Env file ","archived":false,"fork":false,"pushed_at":"2024-10-12T16:19:03.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T05:25:35.154Z","etag":null,"topics":["encryption","secrets","swift","swift-package-manager","xcodecloud"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zunda-pixel.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":"2023-05-08T03:51:44.000Z","updated_at":"2024-10-12T16:18:04.000Z","dependencies_parsed_at":"2024-08-09T20:42:58.904Z","dependency_job_id":"1cded00f-e092-47c8-b0c9-9d29ddb22ecf","html_url":"https://github.com/zunda-pixel/selene","commit_stats":null,"previous_names":["zunda-pixel/genenvcode","zunda-pixel/selene"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/zunda-pixel/selene","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunda-pixel%2Fselene","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunda-pixel%2Fselene/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunda-pixel%2Fselene/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunda-pixel%2Fselene/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zunda-pixel","download_url":"https://codeload.github.com/zunda-pixel/selene/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunda-pixel%2Fselene/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263949409,"owners_count":23534324,"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":["encryption","secrets","swift","swift-package-manager","xcodecloud"],"created_at":"2024-11-02T10:05:20.889Z","updated_at":"2025-07-06T18:12:43.468Z","avatar_url":"https://github.com/zunda-pixel.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Selene\n\n`Selene` is generating obfuscated code for secret Key/Value\n\nhttps://nshipster.com/secrets/\n\n## Sample\n\n\u003cdetails\u003e\u003csummary\u003eGeneratedFile.swift\u003c/summary\u003e\n\n```swift\nimport Algorithms\nimport Foundation\n\npublic enum SecretEnv {\n  static private let cipher: [UInt8] = [\n    0xbe, 0xfe, 0x73, 0xe5, 0xaf, 0x1b, 0x5d, 0xe, 0xae, 0x22, 0x6a, 0x19, 0xcc, 0xdb, 0x9, 0x96,\n    0x33, 0xbf, 0x4c, 0x48, 0x6b, 0x47, 0xf, 0x50, 0x75, 0x93, 0x7e, 0x6b, 0x6e, 0x4a, 0x64, 0xed,\n    0x3c, 0x67, 0x6d, 0xff, 0x20, 0x3f, 0x82, 0x75, 0x29, 0x50, 0x9d, 0x5, 0x8a, 0xd3, 0x3c, 0x88,\n    0xc, 0x82, 0xe, 0xb5, 0xcd, 0x46, 0x6a, 0x42, 0x1, 0xff, 0xd2, 0x28, 0xc9, 0xc3, 0x99, 0x5c,\n  ]\n  static private let _clientSecret: [UInt8] = [0x8c, 0xcc, 0x41, 0xd7]\n  static private let _clientID: [UInt8] = [0x8f, 0xcf, 0x42, 0xd4]\n  static public var clientSecret: String {\n    string(data: _clientSecret, cipher: cipher)\n  }\n  static public var clientID: String {\n    string(data: _clientID, cipher: cipher)\n  }\n  static private func string(data: [UInt8], cipher: [UInt8]) -\u003e String {\n    String.init(decoding: encodeData(data: data, cipher: cipher), as: UTF8.self)\n  }\n  static private func encodeData(data: [UInt8], cipher: [UInt8]) -\u003e [UInt8] {\n    data.indexed().map { offset, element in\n      return element ^ cipher[offset % cipher.count]\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\n```swift\nprint(SecretEnv.clientID)\n```\n\n## Adding Selene as a Dependency\n\nTo use the `Selene` plugin in a SwiftPM project, \nadd the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/zunda-pixel/selene\", from: \"1.2.2\"),\n```\n\n## Use Selene on XcodeCloud\n\n1. add swift-algorithms as a Dependency\n\n```swift\n.package(url: \"https://github.com/apple/swift-algorithms\", from: \"1.0.0\"),\n```\n\n2. set Secret Key/Value on Xcode Cloud `Environment Variable`\n\n\u003cimg width=\"500\" alt=\"xcode-cloud-environment-sample\" src=\"https://github.com/zunda-pixel/GenEnvCode/assets/47569369/09753556-f470-4ecd-b1e5-3aa00fa1f81f\"\u003e\n\n3. add ci_scripts/ci_post_clone.sh [Apple Documents](https://developer.apple.com/documentation/xcode/writing-custom-build-scripts)\n\n```shell\n#!/bin/sh\n\n# ci_post_clone.sh\n\n# install Selene\nbrew tap zunda-pixel/selene\nbrew install zunda-pixel/selene/selene\n\n# change directory to project top from ci_scripts\ncd ..\n\n## set Key/Value as Step 2\n\ncat \u003e .env \u003c\u003cEOL\nclientID=${CLIENT_ID}\nclientSecret=${CLIENT_SECRET}\nEOL\n\nselene {namespace(ex: SecretEnv)} .env {path/to/GeneratingEnv.swift}\n# Ex. selene SecretEnv .env /Sources/Env/SecretEnv.swift\n```\n\n4. use Secret Value in Project\n\n```swift\nprint({set namespace}.clientID)\nprint(SecretEnv.clientID)\nprint(SecretEnv.clientSecret)\n```\n\n## Use Selene on Local\n\n\u003e **Warning**\n\u003e *DO NOT COMMIT GENERATED CODE*\n\n1. add swift-algorithms as a Dependency\n\n```swift\n.package(url: \"https://github.com/zunda-pixel/selene\", from: \"1.2.2\"),\n```\n\n2. install Selene\n\n```shell\nbrew tap zunda-pixel/selene\nbrew install zunda-pixel/selene/selene\n```\n\n3. add `.env` file\n\n```txt\nkey1=value1\n#comment\nkey2=value2\nkey3=value3=value3\n```\n\n4. execute `Selene`\n\n```shell\nselene {namespace(ex: SecretEnv)} {path/to/env_file} {path/to/GeneratingEnv.swift}\n# Ex. selene SecretEnv .env SecretEnv.swift\n```\n\n5. use Secret Value in Project\n\n```swift\nprint({set namespace}.clientID)\nprint(SecretEnv.clientID)\nprint(SecretEnv.clientSecret)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzunda-pixel%2Fselene","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzunda-pixel%2Fselene","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzunda-pixel%2Fselene/lists"}