{"id":1450,"date":"2026-03-23T20:27:20","date_gmt":"2026-03-23T20:27:20","guid":{"rendered":"https:\/\/luduscode.com\/?p=1450"},"modified":"2026-03-23T20:42:10","modified_gmt":"2026-03-23T20:42:10","slug":"encrypting-and-decrypting-data-safely-in-python-with-fernet","status":"publish","type":"post","link":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/","title":{"rendered":"Encrypting and Decrypting Data Safely in Python with Fernet"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Why bother encrypting?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your application stores anything sensitive, a password, an API key, a personal detail, this data should be safely stored. When data leaks from your application or database we still want to secure the data as much as possible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Encryption solves this by transforming your data into something unreadable without the correct key. In this post we will look at Fernet, a symmetric encryption scheme from Python&#8217;s <code>cryptography<\/code> library. It is simple, secure by default, and fast to implement.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is symmetric encryption?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Symmetric encryption uses the same key to both encrypt and decrypt data. One key, two directions. This is different from asymmetric encryption like RSA, which uses a public and private key pair. This means assymetric encryption uses two different keys for encrypting and decrypting. Symmetric encryption is faster and more suited to encrypting data at rest rather than securing a network handshake.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"471\" height=\"101\" src=\"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png\" alt=\"\" class=\"wp-image-1451\" style=\"width:561px;height:auto\" srcset=\"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png 471w, https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey-300x64.png 300w\" sizes=\"(max-width: 471px) 100vw, 471px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Fernet also guarantees that encrypted data cannot be silently tampered with. It includes authentication under the hood, so if the ciphertext gets modified, decryption fails rather than returning corrupted data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installation<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>pip install cryptography<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Generating a key<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Fernet keys are URL-safe base64-encoded 32-byte values. You generate one like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>from cryptography.fernet import Fernet \nkey = Fernet.generate_key() print(key)<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-verse\"><strong>Important:<\/strong> Treat this key like a password. Store it in an environment variable or <code>.env<\/code> file, never in your source code. Lose the key and you lose access to your data. If it leaks your encryption becomes useless. You should not store it on the same database\/channel as your encrypted data itself.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Although I generally like using Django and a settings file, in this example I use dotenv which you can install using <br><code>pip install python-dotenv<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># .env\n<code>FERNET_KEY=your-generated-key-here<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can now import and retrieve our key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import os from dotenvimport load_dotenv load_dotenv() key = os.environ.get(\"FERNET_KEY\")<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can make a utils file specifically for fernet cryptography, this will allow us to easily call the functionality when I need it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nfrom cryptography.fernet import Fernet\n\ndef _get_fernet() -&gt; Fernet:\n    key = os.environ.get(\"FERNET_KEY\")\n    if not key:\n        raise ValueError(\"FERNET_KEY environment variable is not set.\")\n    return Fernet(key.encode())\n\ndef encrypt(value: str) -&gt; str:\n    return _get_fernet().encrypt(value.encode()).decode()\n\ndef decrypt(encrypted: str) -&gt; str:\n    return _get_fernet().decrypt(encrypted.encode()).decode()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A few things worth noting here. Fernet works with bytes, not strings, so <code>.encode()<\/code> converts the input before encryption and <code>.decode()<\/code> brings it back after. The <code>_get_fernet()<\/code> helper keeps key loading in one place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key rotation using MultiFernet<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">At some point you may need to replace your encryption key without losing access to already-encrypted data. Fernet handles this with MultiFernet.<br>You pass a list of keys. For all new encryption we use the first key. On decryption we attempt all keys to ensure compatibility with old data. Key rotation is useful when you want old keys to expire, this improves security and reduces the risk of your current\/new key leaking. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from cryptography.fernet import Fernet, MultiFernet\n\ndef _get_fernet() -> MultiFernet:\n    raw_keys = os.environ.get(\"FERNET_KEYS\", \"\").split(\",\")\n    keys = &#91;Fernet(k.strip().encode()) for k in raw_keys if k.strip()]\n    return MultiFernet(keys)\n\ndef rotate(encrypted: str) -> str:\n    return _get_fernet().rotate(encrypted.encode()).decode()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your `.env` would look like:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FERNET_KEYS=new-key-here,old-key-here<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have re-encrypted all existing records using <code>rotate()<\/code>, you can safely drop the old key from the list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping up<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Fernet gives you solid symmetric encryption with very little setup. Store your key outside your codebase, use <code>MultiFernet<\/code> if you ever need key rotation, and encrypted data in your database becomes a non-issue even if someone gets access to it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a follow-up post we will wire this directly into a Django model so fields can be encrypted and decrypted transparently on save and load.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why bother encrypting? If your application stores anything sensitive, a password, an API key, a personal detail, this data should [&hellip;]<\/p>\n","protected":false},"author":110,"featured_media":1451,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[21],"tags":[31,30],"class_list":["post-1450","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-and-languages","tag-cryptography","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code<\/title>\n<meta name=\"description\" content=\"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code\" \/>\n<meta property=\"og:description\" content=\"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/\" \/>\n<meta property=\"og:site_name\" content=\"Ludus Code\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-23T20:27:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-23T20:42:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png\" \/>\n\t<meta property=\"og:image:width\" content=\"471\" \/>\n\t<meta property=\"og:image:height\" content=\"101\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vincent\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vincent\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/\"},\"author\":{\"name\":\"Vincent\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/#\\\/schema\\\/person\\\/118bc9b9622d454242df2b2a2bbc7cdb\"},\"headline\":\"Encrypting and Decrypting Data Safely in Python with Fernet\",\"datePublished\":\"2026-03-23T20:27:20+00:00\",\"dateModified\":\"2026-03-23T20:42:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/\"},\"wordCount\":453,\"publisher\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/fernetkey.png\",\"keywords\":[\"cryptography\",\"python\"],\"articleSection\":[\"Programming &amp; Languages\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/\",\"url\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/\",\"name\":\"Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/fernetkey.png\",\"datePublished\":\"2026-03-23T20:27:20+00:00\",\"dateModified\":\"2026-03-23T20:42:10+00:00\",\"description\":\"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#primaryimage\",\"url\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/fernetkey.png\",\"contentUrl\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/fernetkey.png\",\"width\":471,\"height\":101},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/encrypting-and-decrypting-data-safely-in-python-with-fernet\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/luduscode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Encrypting and Decrypting Data Safely in Python with Fernet\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/#website\",\"url\":\"https:\\\/\\\/luduscode.com\\\/\",\"name\":\"Ludus Code\",\"description\":\"Online Programming Courses\",\"publisher\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/luduscode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/#organization\",\"name\":\"Ludus Code\",\"url\":\"https:\\\/\\\/luduscode.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/cropped-cropped-android-chrome-512x512-4.png\",\"contentUrl\":\"https:\\\/\\\/luduscode.com\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/cropped-cropped-android-chrome-512x512-4.png\",\"width\":512,\"height\":512,\"caption\":\"Ludus Code\"},\"image\":{\"@id\":\"https:\\\/\\\/luduscode.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/luduscode.com\\\/#\\\/schema\\\/person\\\/118bc9b9622d454242df2b2a2bbc7cdb\",\"name\":\"Vincent\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g\",\"caption\":\"Vincent\"},\"description\":\"I am a software engineer focused on designing and implementing efficient, scalable, and maintainable software systems. I continuously track emerging technologies across industries and deepen my understanding through experimentation and hands-on development.\",\"url\":\"https:\\\/\\\/luduscode.com\\\/author\\\/author-vincenthendriks\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code","description":"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/","og_locale":"en_US","og_type":"article","og_title":"Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code","og_description":"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.","og_url":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/","og_site_name":"Ludus Code","article_published_time":"2026-03-23T20:27:20+00:00","article_modified_time":"2026-03-23T20:42:10+00:00","og_image":[{"width":471,"height":101,"url":"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png","type":"image\/png"}],"author":"Vincent","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Vincent","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#article","isPartOf":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/"},"author":{"name":"Vincent","@id":"https:\/\/luduscode.com\/#\/schema\/person\/118bc9b9622d454242df2b2a2bbc7cdb"},"headline":"Encrypting and Decrypting Data Safely in Python with Fernet","datePublished":"2026-03-23T20:27:20+00:00","dateModified":"2026-03-23T20:42:10+00:00","mainEntityOfPage":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/"},"wordCount":453,"publisher":{"@id":"https:\/\/luduscode.com\/#organization"},"image":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#primaryimage"},"thumbnailUrl":"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png","keywords":["cryptography","python"],"articleSection":["Programming &amp; Languages"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/","url":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/","name":"Encrypting and Decrypting Data Safely in Python with Fernet - Ludus Code","isPartOf":{"@id":"https:\/\/luduscode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#primaryimage"},"image":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#primaryimage"},"thumbnailUrl":"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png","datePublished":"2026-03-23T20:27:20+00:00","dateModified":"2026-03-23T20:42:10+00:00","description":"Learn how to encrypt and decrypt data safely in Python with Fernet. Covers key generation, a clean reusable implementation, and key rotation with MultiFernet.","breadcrumb":{"@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#primaryimage","url":"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png","contentUrl":"https:\/\/luduscode.com\/wp-content\/uploads\/2026\/03\/fernetkey.png","width":471,"height":101},{"@type":"BreadcrumbList","@id":"https:\/\/luduscode.com\/encrypting-and-decrypting-data-safely-in-python-with-fernet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/luduscode.com\/"},{"@type":"ListItem","position":2,"name":"Encrypting and Decrypting Data Safely in Python with Fernet"}]},{"@type":"WebSite","@id":"https:\/\/luduscode.com\/#website","url":"https:\/\/luduscode.com\/","name":"Ludus Code","description":"Online Programming Courses","publisher":{"@id":"https:\/\/luduscode.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/luduscode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/luduscode.com\/#organization","name":"Ludus Code","url":"https:\/\/luduscode.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/luduscode.com\/#\/schema\/logo\/image\/","url":"https:\/\/luduscode.com\/wp-content\/uploads\/2025\/04\/cropped-cropped-android-chrome-512x512-4.png","contentUrl":"https:\/\/luduscode.com\/wp-content\/uploads\/2025\/04\/cropped-cropped-android-chrome-512x512-4.png","width":512,"height":512,"caption":"Ludus Code"},"image":{"@id":"https:\/\/luduscode.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/luduscode.com\/#\/schema\/person\/118bc9b9622d454242df2b2a2bbc7cdb","name":"Vincent","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/034994ebe6ff46d8f8833ae6ea87c0e8dbabf1aa5c3272c9326539644b73d339?s=96&d=mm&r=g","caption":"Vincent"},"description":"I am a software engineer focused on designing and implementing efficient, scalable, and maintainable software systems. I continuously track emerging technologies across industries and deepen my understanding through experimentation and hands-on development.","url":"https:\/\/luduscode.com\/author\/author-vincenthendriks\/"}]}},"_links":{"self":[{"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/posts\/1450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/comments?post=1450"}],"version-history":[{"count":4,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/posts\/1450\/revisions"}],"predecessor-version":[{"id":1456,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/posts\/1450\/revisions\/1456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/media\/1451"}],"wp:attachment":[{"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/media?parent=1450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/categories?post=1450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/luduscode.com\/wp-json\/wp\/v2\/tags?post=1450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}