Ruby on Rails Wednesday, February 27, 2013

hello, everybody.

in ror, we can add a after_filter to a controller.

 def aes_encrypt
    response.body = AesHelper.aes_encrypt(response.body)
  end

 after_filter :aes_encrypt   

and all action's repsonse int the controller can be encrypt.

and my question is , how to decrypt data use before_filter, or anything else.

ex: i want to post json data to /usr/register,   the json data is {"name":"good", "password":"nice"}. encrypt it to 
5B2YC7WzgFmaivnATP1ZLR4sTXB3SsWEUeMpUbcYiylcvHxfSStYIBqwIMCjZAY3

so i post 5B2YC7WzgFmaivnATP1ZLR4sTXB3SsWEUeMpUbcYiylcvHxfSStYIBqwIMCjZAY3  to /usr/register

in action register , i would write code like this:
#### already decrypt.
def register
   User.register(params[:name], params[:passport])
end

so, how can i decrypt 5B2YC7WzgFmaivnATP1ZLR4sTXB3SsWEUeMpUbcYiylcvHxfSStYIBqwIMCjZAY3 before action register to use params directly in register

thanks for anybody's help!!



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/JA4STvbtDMUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment