BVB Source Codes

prettier Show crypto.js Source code

Return Download prettier: download crypto.js Source code - Download prettier Source code - Type:.js
  1. /* @flow */
  2.  
  3. const crypto = require('crypto');
  4.  
  5. let tests = [
  6.   // Hmac is a duplex stream
  7.   function() {
  8.     const hmac = crypto.createHmac('sha256', 'a secret');
  9.  
  10.     hmac.on('readable', () => {
  11.       (hmac.read(): ?(string | Buffer));
  12.       (hmac.read(): number); // 4 errors: null, void, string, Buffer
  13.     });
  14.  
  15.     hmac.write('some data to hash');
  16.     hmac.write(123); // 2 errors: not a string or a Buffer
  17.     hmac.end();
  18.   },
  19.  
  20.   // Hmac supports update and digest functions too
  21.   function(buf: Buffer) {
  22.     const hmac = crypto.createHmac('sha256', 'a secret');
  23.  
  24.     hmac.update('some data to hash');
  25.     hmac.update('foo', 'utf8');
  26.     hmac.update('foo', 'bogus'); // 1 error
  27.     hmac.update(buf);
  28.     hmac.update(buf, 'utf8'); // 1 error: no encoding when passing a buffer
  29.  
  30.     // it's also chainable
  31.     (hmac.update('some data to hash').update(buf).digest(): Buffer);
  32.  
  33.     (hmac.digest('hex'): string);
  34.     (hmac.digest(): Buffer);
  35.     (hmac.digest('hex'): void); // 1 error
  36.     (hmac.digest(): void); // 1 error
  37.   }
  38. ]
  39.  
downloadcrypto.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top