在网上找到了一段代码:
message = CGI.unescape("VXVHWGQra3JpclBiSkpZWW8yMTRzWUVQL0tYajNXMXUyZzFNcFlNcjVVdloxMnhWOFRvdGdPcXhJV256ZEx3MzFkbWhWbG1SSmMzK0NqNHZnS1BPKytTWVRHRFhjN1hWOHlmc3VnNk5rOXRQNzdobnFlOFhPT25NSTVlT3d2QkZiQktvRU5jMWlNdUZKWjFNL0lBbE9WSEVkcXFoMnUzNGtBa0kzRHJMWFd6VEIreHVjVlhSMThxZEQ2VmdKRmtrWXFKQlI4d1k3QU9EbnViVXR2ZWZxZz09LS00bUd0K0g3UTM0RkY1THkrZUt6Slh3PT0%3D--d9847b41c72ceed939cb58acb6cb989d58602d6e")
config = Rails.application.config
key_generator = ActiveSupport::KeyGenerator.new(
config.secret_key_base, iterations: 1000
)
secret = key_generator.generate_key(
config.action_dispatch.encrypted_cookie_salt
)
sign_secret = key_generator.generate_key(
config.action_dispatch.encrypted_signed_cookie_salt
)
encryptor = ActiveSupport::MessageEncryptor.new(
secret, sign_secret
)
encryptor.decrypt_and_verify(message)
但不知该如何运行,是要放到该 app 的工作目录下,还是任意一个地方,需要require
什么吗?