filenames_secure
Obscure filenames of mp4 files - away from being embarrassed by accidently opening family videos at work!
Install with: pip install filenames_secure
Obscure filenames of mp4 files - away from being embarrassed by accidently opening family videos at work!
Usage
Simply $ filenames_secure to obscure and restore.
How it Works
Filenames will be CRC-32'd, with restore record kept in an JSON file in the same folder.
Collisions
If there are hash collisions, a different secure filename will be selected, then the collision check goes again, until there are no collisions - so there should be no risks of getting data lost - however, there are no warranties.
Functional / Stability
If filename A is encoded into B this time, it will be encoded into B again next time, and forever - if there are no collisions that force a change.
Does CRC-32 collide oftenly?
No. It rarely happens. If it occurs, I suggest going out, buying a lottery.
Code
The code is simple:
import os
import abbrs
def current_path():
p = os.path.realpath(__file__)
p = os.path.split(p)[0]
p = os.path.split(p)[-1]
return p
PACKAGE_NAME = current_path()
RC_FILENAME = f'{PACKAGE_NAME}.json'
def make_dat(ls):
def is_mp4(x):
s = x.split('.')
return len(s) >= 2 and (s[-1] == 'mp4' or s[-2] == 'mp4')
def check_collision(d):
for i, v in enumerate(d):
for j in range(i + 1, len(d)):
if d[i][0] == d[j][0]:
return j
dat = [ [ abbrs.cool_hash(i), i ] for i in filter(is_mp4, ls) ]
while True:
i = check_collision(dat)
if i:
print(f'Repairing collision: {dat[i][0]} -> {dat[i][1]}')
dat[i][0] = abbrs.cool_hash(dat[i][0])
else:
break
return dat
def restore():
dat = abbrs.load_json(RC_FILENAME)
for hash, filename in dat:
os.rename(hash, filename)
abbrs.suspend_file(RC_FILENAME)
def secure():
dat = make_dat(os.listdir())
if len(dat) == 0:
print('MP4 files not found.')
return
abbrs.json_dump(RC_FILENAME, dat)
print(abbrs.table([ 'Hash', 'Filename' ], dat))
for hash, filename in dat:
os.rename(filename, hash)
def main():
if os.path.exists(RC_FILENAME):
restore()
else:
secure()
if __name__ == '__main__':
main()
Metadata
Release files for filenames-secure 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| filenames_secure-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for filenames_secure-0.0.8-py3-none-any.whl |
Release files / filenames_secure-0.0.8-py3-none-any.whl
| Download URL | filenames_secure-0.0.8-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef7c0ad10caeb0816da819b9fecc518354ba2c7af8315e2decc0c002fea4eb18
|
|
BLAKE2b-256 checksum How to use checksums |
cdd0d169c87b4ee1a4dc67b6711dd41d87f3edf9c546af1599d91bde828e0178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Security for filenames-secure 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.