1
0
mirror of https://github.com/S2-/securerandomstring.git synced 2025-08-02 18:30:04 +02:00

1.0.0: Add sync API and update async API to pass error to callback as the first argument.

This commit is contained in:
Mark Stosberg
2015-08-27 16:25:30 -04:00
parent 3358bf21fc
commit 1cc664c4fa
5 changed files with 37 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ var srs = require('secure-random-string');
var result = srs();
// Async
srs(function(sr) {
srs(function(err,sr) {
console.log(sr);
});
@@ -40,7 +40,9 @@ srs({length: 256, urlsafe:true}, function(sr) {
## Error handling
Will throw error if there is not enough accumulated entropy to generate cryptographically strong data. In other words, this without callback will not block even if all entropy sources are drained.
An error is possible if there is not enough accumulated entropy to generate cryptographically strong data. In other words, this will not block even if all entropy sources are drained. Note that the sync API throws an exception, while
the async API returns the error to the callback.
## Author