Exemple
Prevent accidental corruption of a package:crypto Digest when accessing its bytes
sha256:37417f5369d0f1097efea2a84bac724b25fa4e4acffbd1991b19bea3c3fa5748
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Cas
- Objectif
- Prevent accidental corruption of a package:crypto Digest when accessing its bytes HOW
- Paquets
- crypto 3.0.7
- Environnement
- dart
- Créé
- 2026-08-17T02:06:52Z
Ce que l'on suppose souvent
The Digest.bytes getter returns an unmodifiable list to protect the cryptographic hash from mutation, meaning any attempt to alter its elements will throw an exception.
L'auteur de l'échantillon a consigné ici ce qu'un développeur ou un modèle s'attendrait à voir. Le contrat ci-dessous est ce qui s'est réellement exécuté.
Contrat
- if (hash.toString() == originalHex) throw Exception('Digest.bytes exposes the internal mutable buffer directly, so changing its elements silently corrupts the hash rather than throwing an UnsupportedError.');
- try { hash.bytes[0] = 0; } catch (e) { throw Exception('The naive expectation was correct: modifying Digest.bytes threw $e'); }
Fichiers
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Télécharger l'artefact vérifié (tar.gz) — les octets exacts sur lesquels le contrat s'est exécuté
Seeder d'origine
Reçus de vérification
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-17 · ed25519:d91480838ac982c9