https://github.com/weavejester/crypto-equality
A small Clojure library for securely comparing strings or byte arrays
https://github.com/weavejester/crypto-equality
Last synced: 6 months ago
JSON representation
A small Clojure library for securely comparing strings or byte arrays
- Host: GitHub
- URL: https://github.com/weavejester/crypto-equality
- Owner: weavejester
- Created: 2013-09-03T15:54:36.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2021-09-18T14:11:06.000Z (over 4 years ago)
- Last Synced: 2025-06-09T17:13:33.456Z (7 months ago)
- Language: Clojure
- Size: 8.79 KB
- Stars: 23
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# crypto-equality
A very small Clojure library for protecting against
[timing attacks][1] when comparing strings or sequences of bytes.
This is useful for comparing user-supplied values against secrets held
by the application, such as tokens or keys.
[1]: https://en.wikipedia.org/wiki/Timing_attack
## Installation
Add the following dependency to your `project.clj` file:
[crypto-equality "1.0.1"]
## Usage
Require the `crypto.equality` namespace:
```clojure
(require '[crypto.equality :as crypto])
```
Then use the `eq?` function to compare strings, byte arrays, or any
ordered sequence of integers.
```clojure
(crypto/eq? "foo" "foo") ;; => true
(crypto/eq? "foo" "bar") ;; => false
```
## License
Copyright © 2021 James Reeves
Distributed under the Eclipse Public License, the same as Clojure.