Code Explainers

Code explainers tagged #base64

rust
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;

Opaque pagination cursors in Rust

pagination serialization base64
Intermediate 8 steps
ruby
require "openssl"
require "base64"
 
module SecureToken

Authenticated encryption with AES-GCM in Ruby

encryption aes-gcm authentication
Advanced 8 steps
ruby
require "base64"
 
module Auth
  module BasicCredentials

Parsing HTTP Basic Auth headers in Ruby

parsing authentication base64
Intermediate 6 steps
python
import base64
import json
from typing import Annotated, Optional
 

Cursor pagination in a FastAPI endpoint

pagination cursor async
Intermediate 9 steps
rust
use base64::engine::general_purpose::{STANDARD, URL_SAFE_NO_PAD};
use base64::{DecodeError, Engine};
 
pub fn encode_standard(data: &[u8]) -> String {

Base64 encode and decode in Rust

base64 encoding error-handling
Beginner 7 steps
ruby
require "base64"
require "json"
 
module Attachment

Packing binary attachments into JSON

serialization base64 json
Intermediate 8 steps
java
public final class HmacJwt {
 
    private static final ObjectMapper MAPPER = new ObjectMapper();
    private static final Base64.Encoder ENCODER = Base64.getUrlEncoder().withoutPadding();

How HMAC-signed JWTs are created and verified

jwt hmac cryptography
Intermediate 9 steps
go
type PostCursor struct {
	CreatedAt time.Time
	ID        int64
}

Keyset pagination with cursors in Go

pagination keyset-cursor database
Intermediate 8 steps
python
import base64
import hashlib
import hmac
import json

Building signed expiring tokens with HMAC

hmac authentication base64
Intermediate 7 steps
java
public final class AesGcmCipher {
 
    private static final String TRANSFORMATION = "AES/GCM/NoPadding";
    private static final int GCM_TAG_BITS = 128;

Authenticated encryption with AES-GCM in Java

cryptography aes-gcm authenticated-encryption
Intermediate 7 steps
rust
use axum::{extract::{Query, State}, http::StatusCode, Json};
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use serde::{Deserialize, Serialize};
use sqlx::PgPool;

Cursor pagination in an Axum handler

cursor-pagination keyset-pagination base64
Advanced 10 steps