Code Explainers
Code explainers tagged #hmac
ruby
require "openssl" require "base32" class TOTP
How TOTP one-time codes work in Ruby
hmac
authentication
totp
Intermediate
7 steps
typescript
import { createParamDecorator, ExecutionContext, UnauthorizedException,
A signed-cookie param decorator in NestJS
custom-decorators
hmac
timing-safe-comparison
Advanced
8 steps
rust
use hmac::{Hmac, Mac}; use sha2::Sha256; use subtle::ConstantTimeEq;
HMAC signing and constant-time verify in Rust
hmac
cryptography
constant-time
Intermediate
7 steps
go
package middleware import ( "crypto/hmac"
Verifying signed URLs with Gin middleware
hmac
middleware
authentication
Intermediate
8 steps
rust
use axum::{ extract::{FromRequestParts, Path, Query}, http::{request::Parts, StatusCode}, response::{IntoResponse, Redirect},
Signed download links as an Axum extractor
hmac
custom-extractor
authentication
Advanced
9 steps
go
package handlers type WebhookEvent struct { ID string `json:"id"`
Verifying and processing webhooks in Gin
webhooks
hmac
idempotency
Intermediate
9 steps
php
<?php final class RememberMeCookie {
Signed remember-me cookies in PHP
authentication
hmac
cookies
Intermediate
8 steps
ruby
class WebhookSignatureConstraint def initialize(provider) @provider = provider end
Verifying webhook signatures with Rails routing constraints
routing constraints
hmac
webhooks
Advanced
7 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
python
import base64 import hashlib import hmac import os
How TOTP two-factor codes work
totp
hmac
authentication
Intermediate
7 steps
ruby
require "openssl" require "json" require "base64"
Building signed session tokens in Ruby
hmac
authentication
cryptography
Intermediate
8 steps
go
package security import ( "crypto/hmac"
Signing and verifying payloads with HMAC in Go
hmac
cryptography
authentication
Intermediate
5 steps
php
<?php namespace App\Http\Middleware;
Verifying GitHub webhook signatures in Laravel
middleware
hmac
webhooks
Intermediate
5 steps
python
import base64 import hashlib import hmac import json
Building signed expiring tokens with HMAC
hmac
authentication
base64
Intermediate
7 steps
php
<?php namespace App\Support;
How TOTP codes are generated in PHP
totp
hmac
two-factor-auth
Advanced
7 steps
php
<?php namespace App\Http\Middleware;
Verifying webhook signatures in Laravel
hmac
middleware
webhooks
Intermediate
7 steps
ruby
require "openssl" require "base64" module WebhookSignature
Signing and verifying webhooks in Ruby
hmac
cryptography
webhooks
Intermediate
7 steps
php
<?php namespace App\Services;
Building signed, expiring download URLs in PHP in Laravel
hmac
url-signing
authentication
Intermediate
7 steps