1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-23 15:19:41 +02:00

Transport controller and file model (#42)

* Transport controller and file model

* Use randomBytes intead of pseudoRandomBytes

* Cover all lines with tests

* Update code style

* Update code style

* View for image block

* Fix serving static files

* Mkdir -p for uploads dirs

* Add default secret param

* Add image Tool

* Update src/utils/objects.js

Co-Authored-By: talyguryn <vitalik7tv@yandex.ru>

* Use vars for image tool colors

* Revert var

* Remove --color-gray-border var

* Update src/controllers/transport.js

Co-Authored-By: talyguryn <vitalik7tv@yandex.ru>

* Add mp4 support for Image Tool
This commit is contained in:
George Berezhnoy 2019-03-11 18:44:00 +03:00 committed by GitHub
parent 82a81ce96a
commit 404fb4642e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 1135 additions and 41 deletions

View file

@ -5,8 +5,29 @@ const crypto = require('crypto');
* @param stringToHash - string to hash
* @returns {string} - binary hash of argument
*/
module.exports = function binaryMD5(stringToHash) {
function binaryMD5(stringToHash) {
return crypto.createHash('md5')
.update(stringToHash)
.digest('binary');
}
/**
* Returns 16 random bytes in hex format
* @return {Promise<string>}
*/
function random16() {
return new Promise((resolve, reject) => {
crypto.randomBytes(16, (err, raw) => {
if (err) {
reject(err);
}
resolve(raw.toString('hex'));
});
});
}
module.exports = {
binaryMD5,
random16
};