Added configuration and made key length configurable
This commit is contained in:
parent
0eed33f42f
commit
b159817a27
3 changed files with 14 additions and 7 deletions
|
@ -2,8 +2,8 @@ var winston = require('winston');
|
|||
|
||||
// For handling serving stored documents
|
||||
|
||||
var DocumentHandler = function() {
|
||||
|
||||
var DocumentHandler = function(options) {
|
||||
this.keyLength = options.keyLength || 20;
|
||||
};
|
||||
|
||||
// TODO implement with FS backend
|
||||
|
@ -45,11 +45,10 @@ DocumentHandler.prototype.handlePost = function(request, response) {
|
|||
};
|
||||
|
||||
// Generate a random key
|
||||
// TODO make length configurable
|
||||
DocumentHandler.prototype.randomKey = function() {
|
||||
var text = '';
|
||||
var keyspace = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
for (var i = 0; i < 6; i++) {
|
||||
for (var i = 0; i < this.keyLength; i++) {
|
||||
text += keyspace.charAt(Math.floor(Math.random() * keyspace.length));
|
||||
}
|
||||
return text;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue