简单的文本加密

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

require "jcode"
$KCODE="u"   #使用utf-8的字符集,解决中文会出现乱码的问题
TEST_OJ="C:/BJ.txt"
puts "请输入文件的路径:"
TEST_FILE_NAME=gets.chomp
if File.exist?(TEST_FILE_NAME)
   outfile=File.new(TEST_OJ,"w")

   File.open(TEST_FILE_NAME,"r") do |infile|
    infile.each_line do |line|
    str=[line].pack("m")   #加密该行
    outfile.puts str
    end
   end

   outfile.close     #关闭输出文件
   infile=File.new(TEST_FILE_NAME,"w")
   File.open(TEST_OJ,"r") do |outfile|
    outfile.each_line do |line|
    infile.puts(line)
    end
   end
   infile.close
   File.delete(TEST_OJ); #删除中间文件
else
puts "#{TEST_FILE_NAME} is no exit!!"
end