Code Explainers
Code explainers tagged #cryptography
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
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
java
package com.example.security; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec;
Salted password hashing with PBKDF2 in Java
password-hashing
pbkdf2
salting
Intermediate
7 steps
go
package token import ( "crypto/rand"
Generating secure random tokens in Go
cryptography
randomness
encoding
Intermediate
5 steps
ruby
require "openssl" require "base64" module WebhookSignature
Signing and verifying webhooks in Ruby
hmac
cryptography
webhooks
Intermediate
7 steps
php
<?php function verifyJwt(string $token, string $secret): array {
Verifying an HS256 JWT in PHP
jwt
hmac
authentication
Intermediate
9 steps