Code Explainers

Code explainers tagged #hashing

rust
use axum::body::Bytes;
use axum::http::{header, HeaderValue, StatusCode};
use axum::response::{IntoResponse, Response};
use serde::Serialize;

Custom Axum responses with per-user ETags

etag trait-implementation generics
Intermediate 7 steps
python
import hashlib
from collections import defaultdict
from pathlib import Path
 

Finding duplicate files by size then hash

hashing file-io deduplication
Intermediate 7 steps
php
<?php
 
namespace App\FeatureFlags;
 

How a feature flag evaluator decides

feature-flags rollout hashing
Intermediate 8 steps
php
<?php
 
namespace App\Queue;
 

Deduplicating a job queue with Redis

deduplication redis atomicity
Advanced 8 steps
ruby
class UserColor
  GOLDEN_RATIO_CONJUGATE = 0.618033988749895
 
  def initialize(username)

Deriving a stable color from a username

hashing color-theory deterministic-mapping
Intermediate 7 steps
python
import hashlib
import json
from fastapi import APIRouter, Request, Response, Depends, HTTPException, status
 

HTTP ETag caching in a FastAPI route

http-caching etag conditional-requests
Intermediate 9 steps
java
public class DuplicateFinder {
 
    public Map<String, List<Path>> findDuplicates(Path root) throws IOException {
        Map<String, List<Path>> byHash = new HashMap<>();

Finding duplicate files by content hash

hashing file-io streams
Intermediate 8 steps
rust
use std::fs::File;
use std::io::{self, Read};
use std::path::Path;
 

Streaming a SHA-256 hash of a file in Rust

hashing buffered-io streaming
Intermediate 5 steps
go
package checksum
 
import (
	"crypto/sha256"

Computing SHA-256 checksums in Go

hashing io-streaming filesystem-walk
Intermediate 7 steps
php
<?php
 
namespace App\Services;
 

Phone verification codes in Laravel

rate-limiting caching hashing
Intermediate 7 steps
ruby
require "digest"
 
class UploadDeduplicator
  CHUNK_SIZE = 64 * 1024

Deduplicating uploads by content hash

hashing deduplication streaming-io
Intermediate 7 steps
python
import hashlib
from pathlib import Path
 
 

Streaming SHA-256 checksums in Python

hashing file-io streaming
Intermediate 6 steps
java
public final class FileChecksum {
 
    private static final char[] HEX = "0123456789abcdef".toCharArray();
 

Streaming a SHA-256 file checksum in Java

hashing streams resource-management
Intermediate 7 steps