我正在Ruby on Rails中的Base64中工作,并且有一个问题:

例如,以下将如何对Base64进行编码/解码?

<a href="myroute?id=<%=@client.id%>"> MY LINK</a>

最佳答案

要创建Base64,请尝试以下操作:

def create_base_64
  begin
    #for create
    a = 1
    b = Base64.encode64(a.to_s)
    # for decoding
    c = Base64.decode64(b)
    puts c
  rescue Exception => e
    puts e
  end
end

为了提高安全性,请尝试将其破解。例如:
b[1] = b[1] << SecureRandom.hex(1)

还有其他操作,您获得了参数b:
b = params[:b]
b[2]=""
b[2]=""
c = base64.decode64(b.to_s)

关于ruby-on-rails - 如何在Ruby on Rails中使用Base64编码?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27947734/

10-16 08:10