Skip to content
Back to skills

Br Crypto

ASecurity

Use better-route 0.6.0 Crypto and CryptoEncoding helpers for secure random token generation, base64url encoding/decoding, hex tokens, and constant-time comparisons. Triggers on Crypto::token, Crypto::tokenHex, Crypto::equals, Crypto::base64UrlEncode, Crypto::base64UrlDecode, PKCE, nonce, state, CSRF token, HMAC compare, or replacing !== token comparisons. Updated 2026-05-02.

  • 22 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 5, 2026
ai-agentsphpgitapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned June 5, 2026

npx -y skills add Lonsdale201/wp-agent-skills --skill br-crypto --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Br Crypto?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Br Crypto
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lonsdale201-br-crypto/badge)](https://www.skillsdirectory.com/skills/lonsdale201-br-crypto)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: br-crypto
description: Use better-route 0.6.0 Crypto and CryptoEncoding helpers for secure random token generation, base64url encoding/decoding, hex tokens, and constant-time comparisons. Triggers on Crypto::token, Crypto::tokenHex, Crypto::equals, Crypto::base64UrlEncode, Crypto::base64UrlDecode, PKCE, nonce, state, CSRF token, HMAC compare, or replacing !== token comparisons. Updated 2026-05-02.
author: Soczó Kristóf
contact: mailto:lonsdale201@hotmail.com
plugin: better-route
plugin-version-tested: "0.6.0"
php-min: "8.1"
last-updated: "2026-05-02"
docs:
  - https://lonsdale201.github.io/better-docs/docs/better-route/agents
source-refs:
  - src/Support/Crypto.php
  - src/Support/CryptoEncoding.php
  - src/Middleware/Jwt/Hs256JwtVerifier.php
  - tests/SecurityPrimitivesTest.php
---

# better-route: Crypto helpers

Use this for small security primitives that should not be reimplemented in plugins: random tokens, base64url encoding, and constant-time comparisons.

## API

```php
use BetterRoute\Support\Crypto;
use BetterRoute\Support\CryptoEncoding;

$state = Crypto::token(32); // base64url by default
$nonce = Crypto::token(32, CryptoEncoding::Base64Url);
$hex = Crypto::tokenHex(32);

$encoded = Crypto::base64UrlEncode($raw);
$raw = Crypto::base64UrlDecode($encoded);

if (!Crypto::equals($expected, $provided)) {
    throw new \BetterRoute\Http\ApiException('Invalid token.', 401, 'invalid_token');
}
```

## Critical rules

- Use `Crypto::equals()` for PKCE verifier comparisons, nonce, state, CSRF, HMAC, and token-bound string comparisons.
- Do not use `!==` for secrets or attacker-controlled token strings.
- `Crypto::token()` uses `random_bytes()` and defaults to base64url.
- `Crypto::base64UrlDecode()` is strict and throws on malformed input.
- `CryptoEncoding` values are `Hex`, `Base64`, and `Base64Url`.

## Cross-references

- Use `br-single-use-token` when the token must be consumed once.
- Use `br-hmac-signature` for signed request verification.
- Use `br-jwks-jwt-auth` for JWT verification; do not hand-roll JWT crypto.

Files in this skill

  • SKILL.md2 KB
  • agents/openai.yaml219 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…