################################################################################ ################################################################################ ############################### Audio Cript Demo ############################# ################################################################################ ################################################################################ #=============================================================================== # Script criado por Renan Tsuneo Hangai Junior # Créditos: # RenanHangai - Script de encriptação de audio # KGC - Dll de encript #=============================================================================== $RTHScript ||= {} $RTHScript["AudioCrypt"] = false if $RTHScript["AudioCrypt"] module AudioCrypt # Chave para ecriptar o arquivo # Poder ser qualquer coisa KEY = "qualquercoisa" # Nome da extensão do arquivo EXT = ".cript" # Nome da DLL DLL_NAME = "Encript.dll" # Nome da pasta Temp do seu jogo # Diretório # WindowsXP: # C:/Duccuments and Settings/Usuário/Configurações Locais/Temp/TEMP_FOLDER/ TEMP_FOLDER = "RTH-Encript-Temp" # Encriptará todos os arquivos da pasta Audio? # Deixe true somente caso você já tenha terminado de criar # seu jogo, e antes de encriptá-lo # OBS: Caso você deixe true, os arquivos serão sempre encriptados # no que causará um bug! ENCRIPT_FILES = false # Encriptará as BGMS? BGM_ENCRIPT = true # Encriptará as BGSS? BGS_ENCRIPT = true # Encriptará as ME? ME_ENCRIPT = true # Encriptará as SE? SE_ENCRIPT = true module_function @@temp_files = [] ENCRIPT_DLL = Win32API.new(DLL_NAME, "EncryptA", "lppplll", "l") DECRIPT_DLL = Win32API.new(DLL_NAME, "DecryptA", "lppplll", "l") def encrypt(infile, outfile, key) ENCRIPT_DLL.call(0, infile, outfile, key, 1, 4096, 65001) end def decrypt(infile, outfile, key) DECRIPT_DLL.call(0, infile, outfile, key, 1, 4096, 65001) end def encript_audio dires = [] dires.push("Audio/BGM") if BGM_ENCRIPT dires.push("Audio/BGS") if BGS_ENCRIPT dires.push("Audio/SE") if SE_ENCRIPT dires.push("Audio/ME") if ME_ENCRIPT for dir in dires for bgm in Dir.entries(dir) next if bgm == "." next if bgm == ".." name = File.basename(bgm) ext = File.extname(bgm) next if ext == EXT original_name = name[0, name.size - ext.size] source = dir + "/" + bgm destiny = (dir + "/" + original_name + EXT).gsub("/", "\\") self.encrypt(source, destiny, KEY) File.delete(source) end end end def decript_audio dires = [] dires.push("Audio/BGM") if BGM_ENCRIPT dires.push("Audio/BGS") if BGS_ENCRIPT dires.push("Audio/SE") if SE_ENCRIPT dires.push("Audio/ME") if ME_ENCRIPT for dir in dires for bgm in Dir.entries(dir) next if bgm == "." next if bgm == ".." name = File.basename(bgm) ext = File.extname(bgm) next if ext != EXT name = name[0, name.size - ext.size] origen = (dir + "/" + bgm).gsub("/", "\\") destiny = (ENV["TEMP"] + "/#{TEMP_FOLDER}/" + dir + "/" + name + ".midi").gsub("/", "\\") @@temp_files.push(destiny) unless @@temp_files.include?(destiny) self.decrypt(origen, destiny, KEY) end end end def create_needed_dirs directory_main = ENV["TEMP"] + "\\#{TEMP_FOLDER}\\" unless File.directory?(directory_main) system("mkdir #{directory_main}") end need_dirs = ["Audio/", "Audio/BGM/", "Audio/BGS/", "Audio/ME/", "Audio/SE/"] for adir in need_dirs dir = adir.gsub("/", "\\") unless File.directory?(directory_main + dir) system("mkdir #{directory_main + dir}") end end end def delete_temp for file in @@temp_files File.delete(file) end @@temp_files = [] end end if AudioCrypt::ENCRIPT_FILES and $DEBUG AudioCrypt.encript_audio print("Encriptação concluída com sucesso") print("Deixe ENCRIPT_FILES false agora") exit end AudioCrypt.create_needed_dirs AudioCrypt.decript_audio module Audio class << self alias game_cript_audio_bgm_play bgm_play alias game_cript_audio_bgs_play bgs_play alias game_cript_audio_me_play me_play alias game_cript_audio_se_play se_play def bgm_play(name, volume=100, pitch=100) real_name = name if AudioCrypt::BGM_ENCRIPT real_name = get_cript_name(name) end game_cript_audio_bgm_play(real_name, volume, pitch) end def bgs_play(name, volume=100, pitch=100) real_name = name if AudioCrypt::BGS_ENCRIPT real_name = get_cript_name(name) end game_cript_audio_bgs_play(real_name, volume, pitch) end def me_play(name, volume=100, pitch=100) real_name = name if AudioCrypt::ME_ENCRIPT real_name = get_cript_name(name) end game_cript_audio_me_play(real_name, volume, pitch) end def se_play(name, volume=100, pitch=100) real_name = name if AudioCrypt::SE_ENCRIPT real_name = get_cript_name(name) end game_cript_audio_se_play(real_name, volume, pitch) end def get_cript_name(name) folder = File.dirname(name) filename = File.basename(name) ext = File.extname(name) for file in Dir.entries(folder) if file.include?(filename) return name if File.extname(file) != AudioCrypt::EXT name = ENV["TEMP"] + "\\#{AudioCrypt::TEMP_FOLDER}\\" + name name.gsub!("\\", "/") break end end return name end end end end