GitHubScrambler

private object GitHubScrambler(source)

A GitHub authentication token that is slightly scrambled (and NOT SECURE).

Though the scrambling uses encryption, it is not actually stored securely, and can be obtained relatively easily by others. Even if GitHubScrambler.KEY and GitHubScrambler.IV were not stored in plaintext, you would eventually have to leak the plaintext token anyway. There is no way around this.

Assume the token is public knowledge: It may be stolen and abused, and it is your responsibility to ensure that the potential for harm is minimised: Use a fine-grained access token that is limited to read/write access for a single repository of a separate user. Do not use your main repo to store issues in, unless you're fine with the worst case of all your issues being deleted. Subscribe to every event in the repository so that you will notice when the token is being abused for spam.

The token is retrieved from a repository, because tokens are only valid for up to one year, but users should be able to report issues even if there has not been an update for more than a year. This means the GitHubScrambler.KEY and GitHubScrambler.IV must not be refreshed between updates, as otherwise previous versions will be unable to unscramble the token.

Properties

Link copied to clipboard
private const val IV: String

The IV to use for (un)scrambling.

Link copied to clipboard
private val IV_SPEC: IvParameterSpec

The IV specification to use for (un)scrambling.

Link copied to clipboard
private const val KEY: String

The "private" key to use for (un)scrambling.

Link copied to clipboard
private val KEY_SPEC: SecretKeySpec

The key specification to use for (un)scrambling.

Link copied to clipboard
private val URL: URL

The URL at which a newer token may be available.

Functions

Link copied to clipboard
private fun createCipher(): Cipher

Instantiates a Cipher for (un)scrambling a token.

Link copied to clipboard
fun getToken(): String

Reads the unscrambled token.

Link copied to clipboard
@JvmStatic
fun main(args: Array<String>)

Runs an interactive session to scramble a token into a file.

Link copied to clipboard
fun scramble(token: String): String

Scrambles the given token.

Link copied to clipboard
fun unscramble(scrambledToken: String): String

Unscrambles the given scrambledToken.