Upload files to "/"
This commit is contained in:
81
ZtWAV-A-1-i-Proto.py
Normal file
81
ZtWAV-A-1-i-Proto.py
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import wave
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def file_to_wav(input_filepath, output_wavpath):
|
||||||
|
print("Encrypting...", end = " ")
|
||||||
|
try:
|
||||||
|
with open(input_filepath, 'rb') as f:
|
||||||
|
raw_data = f.read()
|
||||||
|
|
||||||
|
# Parameters: 1 channel (mono), 1 byte per sample (8-bit), 44100Hz
|
||||||
|
with wave.open(output_wavpath, 'wb') as wav_file:
|
||||||
|
wav_file.setnchannels(1)
|
||||||
|
wav_file.setsampwidth(1) # 1 byte per sample
|
||||||
|
wav_file.setframerate(8000)
|
||||||
|
wav_file.writeframes(raw_data)
|
||||||
|
|
||||||
|
print("Success.")
|
||||||
|
delete_original = input("Remove original file? [Y]/[n] ")
|
||||||
|
if delete_original == "" or delete_original == "Y" or delete_original == "y":
|
||||||
|
os.remove(input_filepath)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Could not encrypt! {e}")
|
||||||
|
|
||||||
|
def wav_to_file(input_wavpath, output_filepath):
|
||||||
|
print("Decrypting...")
|
||||||
|
try:
|
||||||
|
with wave.open(input_wavpath, 'rb') as wav_file:
|
||||||
|
# Get all frames (the actual data)
|
||||||
|
raw_data = wav_file.readframes(wav_file.getnframes())
|
||||||
|
|
||||||
|
with open(output_filepath, 'wb') as f:
|
||||||
|
f.write(raw_data)
|
||||||
|
|
||||||
|
print("Success.")
|
||||||
|
delete_original = input("Remove original file? [Y]/[n] ")
|
||||||
|
if delete_original == "" or delete_original == "Y" or delete_original == "y":
|
||||||
|
os.remove(input_wavpath)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Could not decrypt! {e}")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print("ZtWAV Zipped-p7c-enc-file to WAV | V-A-1-i Proto | by P7MJ")
|
||||||
|
choice = input("[1] Encrypt [2] Decrypt [h] Help [x] Exit\n > ")
|
||||||
|
if choice == "1":
|
||||||
|
print("")
|
||||||
|
while True:
|
||||||
|
unencrypted = input("Name of p7c_enc > ").replace(".p7c_enc", "") + ".p7c_enc"
|
||||||
|
if Path(unencrypted).is_file():
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("Not an option!")
|
||||||
|
encrypted = input("Name of new WAV > ").replace(".wav", "").replace(".WAV", "") + ".wav"
|
||||||
|
file_to_wav(unencrypted, encrypted)
|
||||||
|
print("Disclaimer: Do not play this \"music\" through any speakers, it will probably destroy a couple of friendships. Read the help section for more information.")
|
||||||
|
|
||||||
|
elif choice == "2":
|
||||||
|
print("")
|
||||||
|
while True:
|
||||||
|
pre_decrypt = input("Name of WAV > ").replace(".wav", "").replace(".WAV", "") + ".wav"
|
||||||
|
if Path(pre_decrypt).is_file():
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("Not an option!")
|
||||||
|
post_decrypt = input("Unencrypted file name > ").replace(".p7c_enc", "") + ".p7c_enc"
|
||||||
|
wav_to_file(pre_decrypt, post_decrypt)
|
||||||
|
|
||||||
|
elif choice == "h":
|
||||||
|
print("""HELP SECTION
|
||||||
|
Not an option: Double check if your filename exists! Don't add the extension (although it will work if you type it correctly), and make sure it is a .wav or .p7c_enc, depending on the situation.
|
||||||
|
DO NOT PLAY MUSIC: Do not play the generated WAV! For your own ears and your speaker, please do not! If for any reason you want to, put the volume as low as possible. I actually mean it.
|
||||||
|
""")
|
||||||
|
|
||||||
|
elif choice == "x":
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Not a valid menu choice!")
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user