赞 | 0 |
VIP | 36 |
好人卡 | 18 |
积分 | 1 |
经验 | 7201 |
最后登录 | 2012-7-7 |
在线时间 | 154 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 154 小时
- 注册时间
- 2011-7-9
- 帖子
- 423
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 灵魂の补给 于 2011-8-20 09:01 编辑
这个脚本可以把传入数据加密成bitmap,你可以加入储存PNG脚本,就可以保存下来。也可以从图片中解密数据。
加密细节不公开,请大家也不要去看吧。可以用来加密存档,不过需要设置下。
这个加密,支持汉字。
左上角就是由透明图片填充的数据块。
好了,下载在这里:(这个工程有4种脚本,本脚本请与图上树干右事件对话。)防止此脚本被人使用太多,容易破解,设置了权限。
游客,本帖隐藏的内容需要积分高于 5 才可浏览,您当前积分为 0
脚本部分:
- #==============================================================================
- # ■ Sprite_Save ≮1版块≯
- #------------------------------------------------------------------------------
- # 位图数据库 作者:END66RPG
- # 操作法:
- #Sprite_Save.new(viewport,"加密","save and load")
- # 或者:
- #XXX.update2(mode)
- #XXX.data = "数据"
- #==============================================================================
- class Sprite_Save < Sprite
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # viewport : 显示端口
- # picture : 图片 (Game_Picture)
- #--------------------------------------------------------------------------
- def initialize(viewport, mode, file, data="")
- super(viewport)
- @mode = mode
- @file = file
- @data = data
- update
- end
- def make_png(e)
- eval"self.bitmap.#{e}"
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- if self.bitmap != nil
- self.bitmap.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- #p @file
- self.bitmap = RPG::Cache.picture(@file)#Bitmap.new('Graphics/Icons/gem_02.png')
- self.zoom_x = 10#@picture.zoom_x / 100.0
- self.zoom_y = 10#@picture.zoom_y / 100.0
- case @mode
- when "加密"
- jiami
- when "解密"
- jiemi
- end
- @mode = ""
- end
- #--------------------------------------------------------------------------
- # ● 更新画面2
- #--------------------------------------------------------------------------
- def update2(mode)
- case mode
- when "加密"
- jiami
- when "解密"
- jiemi
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面3
- #--------------------------------------------------------------------------
- def data=(new_data)
- @data = new_data
- end
- end
复制代码- #==============================================================================
- # ■ Sprite
- #------------------------------------------------------------------------------
- #==============================================================================
- #==============================================
- # ■ Sprite_Save ≮2版块≯
- # 解密
- #==============================================
- class Sprite_Save < Sprite
- def jiemi
- data = ""
- break_switch = nil
- for y in 0..(self.bitmap.height-1)
- if break_switch != nil
- break_switch = false
- break
- end
- for x in 0..(self.bitmap.width-1)
- color = self.bitmap.get_pixel(x, y)
- #p"x#{x} y#{y}"
- if color.alpha == 0
- break_switch = true
- break
- end
- if color.alpha.round == 200 #if the data is chinese words,
- red = color.red.round.chr.to_s
- green = color.green.round.chr.to_s
- blue = color.blue.round.chr.to_s
- china_b = "中"
- china_b[0] = red
- china_b[1] = green
- china_b[2] = blue
- #china_b.gsub!(/\\(.)/) { $1 }
- data += china_b#EasyConv.back_chr(china_b).scan(/./)[0]
- next
- end
- data += color.red.round.chr unless color.red.round.chr == "*"
- data += color.green.round.chr unless color.green.round.chr == "*"
- data += color.blue.round.chr unless color.blue.round.chr == "*"
- end
- end
- #p data
- #eval(data)
- #File.open("jiemi.txt","w+").write(data)
- return data
- end
- end
复制代码- #==============================================================================
- # ■ Sprite_Save ≮3版块≯
- #------------------------------------------------------------------------------
- # 加密
- #==============================================================================
- class Sprite_Save < Sprite
- def forward(x)
- if x == (self.bitmap.width-1)#63
- @x = 0
- @y = 1
- else
- @x = 1
- @y = 0
- end
- end
- def jiami
- ##############初始化################
- #data = "print'this game good'"
- #data += ";@mouse_sprite = Sprite.new"
- #data += ";@mouse_sprite.z = 99999"
- #data += ";@mouse_sprite.bitmap = Bitmap.new('Graphics/Pictures/海底生物10.PNG');p'123467890' "
- @data += " "
- data = @data.split("")
- b = []
- x,y = 0,0
- time = 0
- ####################################
- #################取出每个字#########
- data.each{|c|
- time += 1
- 此是中文 = false
- if time == (data.size+1) and b.size > 0 and b.size < 3
- b.push("\n")
- end
- if time==data.size and b.size > 0 and b.size < 3
- b.push(data[-1])
- b.push("\n")
- end
- if b.size >= 3
- ###############普通转码#####################
- b[0]#red
- b[1]#green
- b[2]#blue
- if self.bitmap.get_pixel(x, y).alpha.round == 200
- forward(x)
- y += @y
- @x == 0 ? x = 0 : x += @x
- end
- color = Color.new(b[0][0],b[1][0],b[2][0],255)
- self.bitmap.set_pixel(x, y, color)
- b = []
- #p x
- forward(x)
- y += @y
- @x == 0 ? x = 0 : x += @x
- ################普通转码完毕####################
- end
- if b.size < 3
- if c.size > 1#如果是中文的情况
- if b.size < 3 and b.size > 0
- b.push "*" if b.size == 2
- if b.size == 1
- b.push "*"
- b.push "*"
- end
- if self.bitmap.get_pixel(x, y).alpha.round == 200
- forward(x)
- y += @y
- @x == 0 ? x = 0 : x += @x
-
- end
- color = Color.new(b[0][0],b[1][0],b[2][0],255)
- self.bitmap.set_pixel(x, y, color)
- b = []
- forward(x)
- y += @y
- @x == 0 ? x = 0 : x += @x
- end
-
- if self.bitmap.get_pixel(x, y).alpha.round == 200
- forward(x)
- y += @y
- @x == 0 ? x = 0 : x += @x
- end
- china_b = c#EasyConv.chr(c)#3字节
- #china_b = china_b.scan(/./)#每个字节分割成1组
- if china_b.size < 3
- #p"此“#{i}”字很有可能破解失败!#{b}"
- (3-china_b.size).times{china_b.push("\000")}
- end
- red = china_b[0]#[0]#.to_i#每个字节变成字码
- green = china_b[1]#[0]#.to_i
- blue = china_b[2]#[0]#.to_i
- china_c = Color.new(red,green,blue,200)
- self.bitmap.fill_rect(x, y, 1, 1, china_c)#200 = 中文判断
- #p c
- else
- b.push c
- end
- end
-
- }
- ##############取出每个字-END######################
- end
-
- end
复制代码
|
|