How to make your (Python) code secret

Here’s a way to make your Python code secret:

  1. import os
  2. make a secret with all your code

  3. add this code:
exec(os.environ["code"])
  1. Finished!
1 Like

Yeah but this makes it so you’re the only person who can run it.

3 Likes

How? Everyone can run a repl with secrets.

Well they can run it, but it won’t work.

does this work? Link to the repl

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    exec(os.environ['code'])
  File "/nix/store/python3-3.10.8/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'code'
1 Like

@QwertyQwerty88 @Chiroyce At least you can make your repl “private”

yes, this is what I meant that only owner can run it.

1 Like

Solves nothing and if you want it secret just do not publish it is program with a compiler language offline and share only executables around.

2 Likes

@QwertyQwerty88 Why do other Python repls with secrets work?

Well secrets only work for Repls with webviews.

2 Likes