René's URL Explorer Experiment


Title: Encrypt your data with MessageEncryptor · Issue #10 · jollygoodcode/jollygoodcode.github.io · GitHub

Open Graph Title: Encrypt your data with MessageEncryptor · Issue #10 · jollygoodcode/jollygoodcode.github.io

X Title: Encrypt your data with MessageEncryptor · Issue #10 · jollygoodcode/jollygoodcode.github.io

Description: Rails has a built-in class MessageEncryptor, which uses OpenSSL::Cipher to perform encryption. Read How does MessageEncryptor works or the source code if you are interested in its inner workings. If you have been working with Ruby for a ...

Open Graph Description: Rails has a built-in class MessageEncryptor, which uses OpenSSL::Cipher to perform encryption. Read How does MessageEncryptor works or the source code if you are interested in its inner workings. I...

X Description: Rails has a built-in class MessageEncryptor, which uses OpenSSL::Cipher to perform encryption. Read How does MessageEncryptor works or the source code if you are interested in its inner workings. I...

Opengraph URL: https://github.com/jollygoodcode/jollygoodcode.github.io/issues/10

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Encrypt your data with MessageEncryptor","articleBody":"Rails has a built-in class [MessageEncryptor](http://api.rubyonrails.org/classes/ActiveSupport/MessageEncryptor.html), which uses [OpenSSL::Cipher](http://ruby-doc.org/stdlib-2.2.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html) to perform encryption. Read [How does MessageEncryptor works](http://www.monkeyandcrow.com/blog/reading_rails_how_does_message_encryptor_work) or [the source code](https://github.com/rails/rails/blob/4f51433/activesupport/lib/active_support/message_encryptor.rb) if you are interested in its inner workings.\n\nIf you have been working with Ruby for a while, you would probably be familiar with `attr_accessor`, `attr_reader` and `attr_writer` which provide you with getter and/or setter. These methods are mostly convenient, but if you are required to store sensitive information in the database (i.e. OAuth token), then you will need your own custom getter and setter to protect the sensitive data.\n\nYou can make use of the `#encrypt_and_sign` and `#decrypt_and_verify` methods available in Rails to encrypt and decrypt data in your custom getter and setter, and here's how you can do it:\n\n``` ruby\ndef token=(value)\n  encrypted_token = cryptor.encrypt_and_sign(value)\n  self[:token] = encrypted_token\nend\n\ndef token\n  encrypted_token = self[:token]\n\n  if encrypted_token.present?\n    cryptor.decrypt_and_verify(encrypted_token)\n  end\nend\n\nprivate\n\n  def cryptor\n    ActiveSupport::MessageEncryptor.new(Rails.application.secrets.secret_key_base)\n  end\n```\n\nFeeling paranoid? You can also pass in additional cipher:\n\n``` ruby\nActiveSupport::MessageEncryptor.new(\n  Rails.application.secrets.secret_key_base,\n  cipher: \"aes-256-ecb\"\n)\n```\n\nPro-tip: You can get a list of available ciphers with `$ openssl list-cipher-commands`.\n\nTesting it is also very simple (with RSpec):\n\n``` ruby\ndescribe \"#token=\" do\n  it \"saves encrypted token in database\" do\n    user = build(:user)\n    user.token = \"oauth token\"\n\n    user.save\n\n    expect(user[\"token\"]).not_to eq(\"oauth token\")\n  end\nend\n\ndescribe \"#token\" do\n  it \"returns decrypted token upon retrieval\" do\n    user = build(:user)\n    user.token = \"oauth token\"\n\n    user.save\n\n    expect(user.reload.token).to eq(\"oauth token\")\n  end\nend\n```\n\nNote that I have used [FactoryGirl](https://github.com/thoughtbot/factory_girl) to perform a `build(:user)`. \n\nAlternatively, if you need a lot more features for your encrypted fields, you can also check out [attr_encrypted gem](https://github.com/attr-encrypted/attr_encrypted).\n\nRemember to secure sensitive information you store in your database! :heart:\n## \n\nThanks for reading! \n\n@JuanitoFatas :pencil2: [Jolly Good Code](http://www.jollygoodcode.com)\n### About Jolly Good Code\n\n[![Jolly Good Code](https://cloud.githubusercontent.com/assets/1000669/9362336/72f9c406-46d2-11e5-94de-5060e83fcf83.jpg)](http://www.jollygoodcode.com)\n\nWe specialise in Agile practices and Ruby, and we love contributing to open source. \n[Speak to us](http://www.jollygoodcode.com/#get-in-touch) about your next big idea, or [check out our projects](http://www.jollygoodcode.com/open-source).  \n","author":{"url":"https://github.com/JuanitoFatas","@type":"Person","name":"JuanitoFatas"},"datePublished":"2015-11-17T07:47:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/10/jollygoodcode.github.io/issues/10"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:10c6fd15-a7be-9a77-0f0b-fc0e33583567
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDB58:3CD7D9:9ADC1AE:D28A984:6A5EDE20
html-safe-nonce918df6ffa3e873de53fed9e5271ac7e96526bdf2224244b3e88cc2160b363b4d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjU4OjNDRDdEOTo5QURDMUFFOkQyOEE5ODQ6NkE1RURFMjAiLCJ2aXNpdG9yX2lkIjoiNTQxNDUzNTE2ODcwMjQ3MTcxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac79f2d8de282c1ac73154a67e4d0f9f483ea9c69084568bd4413f9cfca180a08b
hovercard-subject-tagissue:117302220
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/jollygoodcode/jollygoodcode.github.io/10/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c92443ba9ca8169c63bb1bc65dede17e6a1a9514a2e803ccbaf3e5b36a1dab52/jollygoodcode/jollygoodcode.github.io/issues/10
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c92443ba9ca8169c63bb1bc65dede17e6a1a9514a2e803ccbaf3e5b36a1dab52/jollygoodcode/jollygoodcode.github.io/issues/10
og:image:altRails has a built-in class MessageEncryptor, which uses OpenSSL::Cipher to perform encryption. Read How does MessageEncryptor works or the source code if you are interested in its inner workings. I...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJuanitoFatas
hostnamegithub.com
expected-hostnamegithub.com
None82d0004a35927bdb00c652a57f456c55aa0eda4ade1bc7956d7510fdea6e454b
turbo-cache-controlno-preview
go-importgithub.com/jollygoodcode/jollygoodcode.github.io git https://github.com/jollygoodcode/jollygoodcode.github.io.git
octolytics-dimension-user_id5326832
octolytics-dimension-user_loginjollygoodcode
octolytics-dimension-repository_id39484578
octolytics-dimension-repository_nwojollygoodcode/jollygoodcode.github.io
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id39484578
octolytics-dimension-repository_network_root_nwojollygoodcode/jollygoodcode.github.io
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released2d913dd727d2d7ac189fb4d05b10bc34ecd03ee
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fjollygoodcode%2Fjollygoodcode.github.io%2Fissues%2F10
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fjollygoodcode%2Fjollygoodcode.github.io%2Fissues%2F10
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=jollygoodcode%2Fjollygoodcode.github.io
Reloadhttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10
Reloadhttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10
Reloadhttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10
Please reload this pagehttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10
jollygoodcode https://github.com/jollygoodcode
jollygoodcode.github.iohttps://github.com/jollygoodcode/jollygoodcode.github.io
Notifications https://github.com/login?return_to=%2Fjollygoodcode%2Fjollygoodcode.github.io
Fork 4 https://github.com/login?return_to=%2Fjollygoodcode%2Fjollygoodcode.github.io
Star 136 https://github.com/login?return_to=%2Fjollygoodcode%2Fjollygoodcode.github.io
Code https://github.com/jollygoodcode/jollygoodcode.github.io
Issues 21 https://github.com/jollygoodcode/jollygoodcode.github.io/issues
Pull requests 0 https://github.com/jollygoodcode/jollygoodcode.github.io/pulls
Actions https://github.com/jollygoodcode/jollygoodcode.github.io/actions
Projects https://github.com/jollygoodcode/jollygoodcode.github.io/projects
Wiki https://github.com/jollygoodcode/jollygoodcode.github.io/wiki
Security and quality 0 https://github.com/jollygoodcode/jollygoodcode.github.io/security
Insights https://github.com/jollygoodcode/jollygoodcode.github.io/pulse
Code https://github.com/jollygoodcode/jollygoodcode.github.io
Issues https://github.com/jollygoodcode/jollygoodcode.github.io/issues
Pull requests https://github.com/jollygoodcode/jollygoodcode.github.io/pulls
Actions https://github.com/jollygoodcode/jollygoodcode.github.io/actions
Projects https://github.com/jollygoodcode/jollygoodcode.github.io/projects
Wiki https://github.com/jollygoodcode/jollygoodcode.github.io/wiki
Security and quality https://github.com/jollygoodcode/jollygoodcode.github.io/security
Insights https://github.com/jollygoodcode/jollygoodcode.github.io/pulse
Encrypt your data with MessageEncryptorhttps://github.com/jollygoodcode/jollygoodcode.github.io/issues/10#top
Bloghttps://github.com/jollygoodcode/jollygoodcode.github.io/issues?q=state%3Aopen%20label%3A%22Blog%22
https://github.com/JuanitoFatas
JuanitoFatashttps://github.com/JuanitoFatas
on Nov 17, 2015https://github.com/jollygoodcode/jollygoodcode.github.io/issues/10#issue-117302220
MessageEncryptorhttp://api.rubyonrails.org/classes/ActiveSupport/MessageEncryptor.html
OpenSSL::Cipherhttp://ruby-doc.org/stdlib-2.2.3/libdoc/openssl/rdoc/OpenSSL/Cipher.html
How does MessageEncryptor workshttp://www.monkeyandcrow.com/blog/reading_rails_how_does_message_encryptor_work
the source codehttps://github.com/rails/rails/blob/4f51433/activesupport/lib/active_support/message_encryptor.rb
FactoryGirlhttps://github.com/thoughtbot/factory_girl
attr_encrypted gemhttps://github.com/attr-encrypted/attr_encrypted
@JuanitoFatashttps://github.com/JuanitoFatas
Jolly Good Codehttp://www.jollygoodcode.com
http://www.jollygoodcode.com
Speak to ushttp://www.jollygoodcode.com/#get-in-touch
check out our projectshttp://www.jollygoodcode.com/open-source
Bloghttps://github.com/jollygoodcode/jollygoodcode.github.io/issues?q=state%3Aopen%20label%3A%22Blog%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.