LoginSignup
1
1

More than 5 years have passed since last update.

Ruby on Rails5で文字列データから可逆なtokenを簡単に作成するメモ

Posted at

Rails.version => "5.2.1"
RUBY_VERSION => "2.5.1"

JSON Web Token (JWT)がデフォで使えるので一番楽そう

encode
data = 'hogehoge'
token = JWT.encode(data, Rails.application.credentials.config[:secret_key_base])
decode
data, header = JWT.decode(token, Rails.application.credentials.config[:secret_key_base])
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1