Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blakejs

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blakejs - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

blake2s.js

44

blake2b.js

@@ -5,17 +5,3 @@ // Blake2B in pure Javascript

// For debugging: prints out hash state in the same format as the RFC
// sample computation
// function DebugPrint (label, arr) {
// var msg = '\n' + label + ' = '
// for (var i = 0; i < arr.length; i += 2) {
// msg += (0x100000000 + arr[i + 1]).toString(16).substring(1).toUpperCase()
// msg += (0x100000000 + arr[i]).toString(16).substring(1).toUpperCase()
// if (i % 6 === 4) {
// msg += '\n' + new Array(label.length + 4).join(' ')
// } else if (i < arr.length - 1) {
// msg += ' '
// }
// }
// console.log(msg)
// }
var util = require('./util')

@@ -156,5 +142,5 @@ // 64-bit unsigned addition

// and match the RFC sample documentation
// DebugPrint(' m[16]', m)
// util.debugPrint(' m[16]', m, 64)
for (i = 0; i < 12; i++) {
// DebugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v)
// util.debugPrint(' (i=' + (i < 10 ? ' ' : '') + i + ') v[16]', v, 64)
B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1])

@@ -169,3 +155,3 @@ B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3])

}
// DebugPrint(' (i=12) v[16]', v)
// util.debugPrint(' (i=12) v[16]', v, 64)

@@ -175,3 +161,3 @@ for (i = 0; i < 16; i++) {

}
// DebugPrint('h[8]', ctx.h)
// util.debugPrint('h[8]', ctx.h, 64)
}

@@ -256,12 +242,3 @@

outlen = outlen || 64
if (typeof (input) === 'string') {
var str = input
input = new Uint8Array(str.length)
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) > 255) {
throw new Error('Input must be an ASCII string or Uint8Array')
}
input[i] = str.charCodeAt(i)
}
}
input = util.normalizeInput(input)

@@ -284,5 +261,3 @@ // do the math

var output = blake2b(input, key, outlen)
return Array.prototype.map.call(output, function (n) {
return (n < 16 ? '0' : '') + n.toString(16)
}).join('')
return util.toHex(output)
}

@@ -292,3 +267,6 @@

blake2b: blake2b,
blake2bHex: blake2bHex
blake2bHex: blake2bHex,
blake2b_init: blake2b_init,
blake2b_update: blake2b_update,
blake2b_final: blake2b_final
}
{
"name": "blakejs",
"version": "0.3.0",
"description": "Pure Javascript implementation of the BLAKE2B hash function",
"version": "0.4.0",
"description": "Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions",
"main": "blake2b.js",
"scripts": {
"test": "standard && node test_blake2b.js"
"test": "standard && node test_blake2b.js && node test_blake2s.js"
},

@@ -9,0 +9,0 @@ "devDependencies": {

BLAKE.js
====
Pure Javascript implementation of the BLAKE2B hash function.
Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions.
```js
var Blake = require('blake')
console.log(Blake.blake2bHex('hello world'))
var blake = require('blake')
console.log(blake.blake2bHex('hello world'))
// prints ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923
console.log(blake.blake2sHex('abc'))
// prints 508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982
```

@@ -53,3 +56,4 @@

```
15.2 MB / second on a 2.2GHz i7-4770HQ
BLAKE2b: 15.2 MB / second on a 2.2GHz i7-4770HQ
BLAKE2s: 20 MB / second

@@ -56,0 +60,0 @@ ¯\_(ツ)_/¯

var test = require('tape')
var blake2b = require('./blake2b')
var util = require('./util')
var fs = require('fs')

@@ -49,21 +50,3 @@

console.log('Benchmarking BLAKE2b(' + (N >> 20) + ' MB input)')
var startMs = new Date().getTime()
var input = new Uint8Array(N)
for (var i = 0; i < N; i++) {
input[i] = i % 256
}
var genMs = new Date().getTime()
console.log('Generated random input in ' + (genMs - startMs) + 'ms')
startMs = genMs
for (i = 0; i < RUNS; i++) {
var hashHex = blake2bHex(input)
var hashMs = new Date().getTime()
var ms = hashMs - startMs
startMs = hashMs
console.log('Hashed in ' + ms + 'ms: ' + hashHex.substring(0, 20) + '...')
console.log(Math.round(N / (1 << 20) / (ms / 1000) * 100) / 100 + ' MB PER SECOND')
}
util.testSpeed(blake2bHex, N, RUNS)
t.end()

@@ -70,0 +53,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc