Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <h1 align="center">
  2. <br>
  3. <br>
  4. <br>
  5. <img width="380" src="media/logo.svg" alt="hasha">
  6. <br>
  7. <br>
  8. <br>
  9. <br>
  10. <br>
  11. </h1>
  12. > Hashing made simple. Get the hash of a buffer/string/stream/file.
  13. [![Build Status](https://travis-ci.com/sindresorhus/hasha.svg?branch=master)](https://travis-ci.com/github/sindresorhus/hasha)
  14. Convenience wrapper around the core [`crypto` Hash class](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) with simpler API and better defaults.
  15. ## Install
  16. ```
  17. $ npm install hasha
  18. ```
  19. ## Usage
  20. ```js
  21. const hasha = require('hasha');
  22. hasha('unicorn');
  23. //=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
  24. ```
  25. ```js
  26. const hasha = require('hasha');
  27. (async () => {
  28. console.log(await hasha.async('unicorn'));
  29. //=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
  30. })();
  31. ```
  32. ```js
  33. const hasha = require('hasha');
  34. // Hash the process input and output the hash sum
  35. process.stdin.pipe(hasha.stream()).pipe(process.stdout);
  36. ```
  37. ```js
  38. const hasha = require('hasha');
  39. (async () => {
  40. // Get the MD5 hash of an image
  41. const hash = await hasha.fromFile('unicorn.png', {algorithm: 'md5'});
  42. console.log(hash);
  43. //=> '1abcb33beeb811dca15f0ac3e47b88d9'
  44. })();
  45. ```
  46. ## API
  47. See the Node.js [`crypto` docs](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options) for more about hashing.
  48. ### hasha(input, options?)
  49. Returns a hash.
  50. #### input
  51. Type: `Buffer | string | Array<Buffer | string>`
  52. Buffer you want to hash.
  53. While strings are supported you should prefer buffers as they're faster to hash. Although if you already have a string you should not convert it to a buffer.
  54. Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
  55. #### options
  56. Type: `object`
  57. ##### encoding
  58. Type: `string`\
  59. Default: `'hex'`\
  60. Values: `'hex' | 'base64' | 'buffer' | 'latin1'`
  61. Encoding of the returned hash.
  62. ##### algorithm
  63. Type: `string`\
  64. Default: `'sha512'`\
  65. Values: `'md5' | 'sha1' | 'sha256' | 'sha512'` *([Platform dependent](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options))*
  66. *The `md5` algorithm is good for [file revving](https://github.com/sindresorhus/rev-hash), but you should never use `md5` or `sha1` for anything sensitive. [They're insecure.](https://security.googleblog.com/2014/09/gradually-sunsetting-sha-1.html)*
  67. ### hasha.async(input, options?)
  68. In Node.js 12 or later, the operation is executed using `worker_threads`. A thread is lazily spawned on the first operation and lives until the end of the program execution. It's unrefed, so it won't keep the process alive.
  69. Returns a hash asynchronously.
  70. ### hasha.stream(options?)
  71. Returns a [hash transform stream](https://nodejs.org/api/crypto.html#crypto_class_hash).
  72. ### hasha.fromStream(stream, options?)
  73. Returns a `Promise` for the calculated hash.
  74. ### hasha.fromFile(filepath, options?)
  75. In Node.js 12 or later, the operation is executed using `worker_threads`. A thread is lazily spawned on the first operation and lives until the end of the program execution. It's unrefed, so it won't keep the process alive.
  76. Returns a `Promise` for the calculated file hash.
  77. ### hasha.fromFileSync(filepath, options?)
  78. Returns the calculated file hash.
  79. ## Related
  80. - [hasha-cli](https://github.com/sindresorhus/hasha-cli) - CLI for this module
  81. - [crypto-hash](https://github.com/sindresorhus/crypto-hash) - Tiny hashing module that uses the native crypto API in Node.js and the browser
  82. - [hash-obj](https://github.com/sindresorhus/hash-obj) - Get the hash of an object
  83. - [md5-hex](https://github.com/sindresorhus/md5-hex) - Create a MD5 hash with hex encoding