密钥打包文件
#一个简单的脚本,通过密钥读取和写入文件,用于特殊场合。#Fpack.pack(filename)打包#Fpack.dump(filename)还原#打包后文件会被压缩#以下是脚本begin#密钥输入,不限制个数,不能用数字。例:= #个数不能为零$passad = endmodule Fpack#初始化读取def self.dump(filename) file = File.open(filename, rb) data = file.read temp = Zlib::Inflate.inflate(data) file.close file = File.open(filename,wb) file.write(temp) file.close temp = $passad.reverse for i in 0...temp.size pack_load(temp,filename) endenddef self.pack_load(passad ,filename) file = File.open(filename, rb) eval(#{passad} = Marshal.load(file)) file.close file = File.open(filename,wb) file.write(eval(#{passad})) file.closeend#初始化写入def self.pack(filename) for i in 0...$passad.size pack_save($passad,filename) end file = File.open(filename,rb) data = file.read temp = Zlib::Deflate.deflate(data,6) file.close file = File.open(filename,wb) file.write(temp) file.close enddef self.pack_save(passad ,filename) f = File.open(filename, rb) eval(#{passad} = f.read) f.close file = File.open(filename,wb) Marshal.dump(eval(#{passad}), file) file.closeendend复制代码本帖来自P1论坛作者赤点,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=129883若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]