https://github.com/paragonie/poly1305-js
JavaScript implementation of the Poly1305 one-time authenticator
https://github.com/paragonie/poly1305-js
Last synced: 3 months ago
JSON representation
JavaScript implementation of the Poly1305 one-time authenticator
- Host: GitHub
- URL: https://github.com/paragonie/poly1305-js
- Owner: paragonie
- Created: 2019-05-04T15:00:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T02:41:38.000Z (over 1 year ago)
- Last Synced: 2025-10-04T03:41:21.246Z (8 months ago)
- Language: JavaScript
- Size: 186 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Poly1305 (JavaScript)
[](https://github.com/paragonie/poly1305-js/actions)
[](https://npm.im/poly1305-js)
This is a pure JavaScript implementation of Poly1305.
## Installing this Library
```
npm install poly1305-js
```
## Using this Library
Usage is straightforward.
```javascript
const Poly1305 = require('poly1305-js');
(async function() {
let message = Buffer.from("test message");
let key = Buffer.from('808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f', 'hex');
let tag = await Poly1305.onetimeauth(message, key);
if (await Poly1305.onetimeauth_verify(message, key, tag)) {
console.log('success');
}
// Streaming API
let auth = new Poly1305(key);
await auth.update(message);
await auth.update(Buffer.from('some additional data'));
tag = await auth.finish();
console.log(tag);
})();
```