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.4.7 to 1.0.0

.travis.yml

26

blake2b.js

@@ -119,3 +119,3 @@ // Blake2B in pure Javascript

var m = new Uint32Array(32)
function blake2b_compress (ctx, last) {
function blake2bCompress (ctx, last) {
var i = 0

@@ -171,3 +171,3 @@

// Takes an optional Uint8Array key
function blake2b_init (outlen, key) {
function blake2bInit (outlen, key) {
if (outlen === 0 || outlen > 64) {

@@ -198,3 +198,3 @@ throw new Error('Illegal output length, expected 0 < length <= 64')

if (key) {
blake2b_update(ctx, key)
blake2bUpdate(ctx, key)
// at the end

@@ -209,7 +209,7 @@ ctx.c = 128

// Requires hash context and Uint8Array (byte array)
function blake2b_update (ctx, input) {
function blake2bUpdate (ctx, input) {
for (var i = 0; i < input.length; i++) {
if (ctx.c === 128) { // buffer full ?
ctx.t += ctx.c // add counters
blake2b_compress(ctx, false) // compress (not last)
blake2bCompress(ctx, false) // compress (not last)
ctx.c = 0 // counter to zero

@@ -223,3 +223,3 @@ }

// Returns a Uint8Array containing the message digest
function blake2b_final (ctx) {
function blake2bFinal (ctx) {
ctx.t += ctx.c // mark last block offset

@@ -230,3 +230,3 @@

}
blake2b_compress(ctx, true) // final block flag = 1
blake2bCompress(ctx, true) // final block flag = 1

@@ -255,5 +255,5 @@ // little endian convert and store

// do the math
var ctx = blake2b_init(outlen, key)
blake2b_update(ctx, input)
return blake2b_final(ctx)
var ctx = blake2bInit(outlen, key)
blake2bUpdate(ctx, input)
return blake2bFinal(ctx)
}

@@ -277,5 +277,5 @@

blake2bHex: blake2bHex,
blake2b_init: blake2b_init,
blake2b_update: blake2b_update,
blake2b_final: blake2b_final
blake2bInit: blake2bInit,
blake2bUpdate: blake2bUpdate,
blake2bFinal: blake2bFinal
}

@@ -53,3 +53,3 @@ // BLAKE2s hash function in pure Javascript

var m = new Uint32Array(16)
function blake2s_compress (ctx, last) {
function blake2sCompress (ctx, last) {
var i = 0

@@ -97,3 +97,3 @@ for (i = 0; i < 8; i++) { // init work variables

// Takes an optional Uint8Array key
function blake2s_init (outlen, key) {
function blake2sInit (outlen, key) {
if (!(outlen > 0 && outlen <= 32)) {

@@ -117,3 +117,3 @@ throw new Error('Incorrect output length, should be in [1, 32]')

if (keylen > 0) {
blake2s_update(ctx, key)
blake2sUpdate(ctx, key)
ctx.c = 64 // at the end

@@ -127,7 +127,7 @@ }

// Requires hash context and Uint8Array (byte array)
function blake2s_update (ctx, input) {
function blake2sUpdate (ctx, input) {
for (var i = 0; i < input.length; i++) {
if (ctx.c === 64) { // buffer full ?
ctx.t += ctx.c // add counters
blake2s_compress(ctx, false) // compress (not last)
blake2sCompress(ctx, false) // compress (not last)
ctx.c = 0 // counter to zero

@@ -141,3 +141,3 @@ }

// Returns a Uint8Array containing the message digest
function blake2s_final (ctx) {
function blake2sFinal (ctx) {
ctx.t += ctx.c // mark last block offset

@@ -147,3 +147,3 @@ while (ctx.c < 64) { // fill up with zeros

}
blake2s_compress(ctx, true) // final block flag = 1
blake2sCompress(ctx, true) // final block flag = 1

@@ -172,5 +172,5 @@ // little endian convert and store

// do the math
var ctx = blake2s_init(outlen, key)
blake2s_update(ctx, input)
return blake2s_final(ctx)
var ctx = blake2sInit(outlen, key)
blake2sUpdate(ctx, input)
return blake2sFinal(ctx)
}

@@ -194,5 +194,5 @@

blake2sHex: blake2sHex,
blake2s_init: blake2s_init,
blake2s_update: blake2s_update,
blake2s_final: blake2s_final
blake2sInit: blake2sInit,
blake2sUpdate: blake2sUpdate,
blake2sFinal: blake2sFinal
}
var b2b = require('./blake2b')
var b2s = require('./blake2s')
module.exports = Object.assign({}, b2b, b2s)
module.exports = {
blake2b: b2b.blake2b,
blake2bHex: b2b.blake2bHex,
blake2bInit: b2b.blake2bInit,
blake2bUpdate: b2b.blake2bUpdate,
blake2bFinal: b2b.blake2bFinal,
blake2s: b2s.blake2s,
blake2sHex: b2s.blake2sHex,
blake2sInit: b2s.blake2sInit,
blake2sUpdate: b2s.blake2sUpdate,
blake2sFinal: b2s.blake2sFinal
}
{
"name": "blakejs",
"version": "0.4.7",
"version": "1.0.0",
"description": "Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions",

@@ -5,0 +5,0 @@ "main": "index.js",

BLAKE.js
====
[![travis ci](https://travis-ci.org/dcposch/blakejs.svg?branch=master)](https://travis-ci.org/dcposch/blakejs)
[![npm version](https://badge.fury.io/js/blakejs.svg)](https://badge.fury.io/js/blakejs)
Pure Javascript implementation of the BLAKE2b and BLAKE2s hash functions.

@@ -5,0 +8,0 @@

@@ -7,5 +7,5 @@ var test = require('tape')

var blake2sHex = b2s.blake2sHex
var blake2s_init = b2s.blake2s_init
var blake2s_update = b2s.blake2s_update
var blake2s_final = b2s.blake2s_final
var blake2sInit = b2s.blake2sInit
var blake2sUpdate = b2s.blake2sUpdate
var blake2sFinal = b2s.blake2sFinal

@@ -32,20 +32,20 @@ test('BLAKE2s basic', function (t) {

// Parameter sets
var b2s_md_len = [16, 20, 28, 32]
var b2s_in_len = [0, 3, 64, 65, 255, 1024]
var outputLengths = [16, 20, 28, 32]
var inputLengths = [0, 3, 64, 65, 255, 1024]
// 256-bit hash for testing
var ctx = blake2s_init(32)
var ctx = blake2sInit(32)
for (var i = 0; i < 4; i++) {
var outlen = b2s_md_len[i]
var outlen = outputLengths[i]
for (var j = 0; j < 6; j++) {
var inlen = b2s_in_len[j]
var inlen = inputLengths[j]
var arr = selftest_seq(inlen, inlen)
var arr = generateInput(inlen, inlen)
var hash = blake2s(arr, null, outlen) // unkeyed hash
blake2s_update(ctx, hash) // hash the hash
blake2sUpdate(ctx, hash) // hash the hash
var key = selftest_seq(outlen, outlen)
var key = generateInput(outlen, outlen)
hash = blake2s(arr, key, outlen) // keyed hash
blake2s_update(ctx, hash) // hash the hash
blake2sUpdate(ctx, hash) // hash the hash
}

@@ -55,3 +55,3 @@ }

// Compute and compare the hash of hashes
var finalHash = blake2s_final(ctx)
var finalHash = blake2sFinal(ctx)
t.equal(toHex(finalHash), toHex(expectedHash))

@@ -62,3 +62,3 @@ t.end()

// Returns a Uint8Array of len bytes
function selftest_seq (len, seed) {
function generateInput (len, seed) {
var out = new Uint8Array(len)

@@ -65,0 +65,0 @@ var a = new Uint32Array(3)

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