HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/alq-cali.bikenow.co/node_modules/crypto-browserify/test/create-hash.js
'use strict';

var test = require('tape');
var satisfies = require('semver').satisfies;

var algorithms = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'];
var encodings = ['hex', 'base64']; // FIXME: test binary
var vectors = require('hash-test-vectors');

function runTest(name, createHash, algorithm) {
	var isUnsupported = satisfies(process.version, '^17') && (
		algorithm === 'rmd160'
		|| algorithm === 'hmac(rmd160)'
	);
	test(
		name + ' test ' + algorithm + ' against test vectors',
		{ skip: isUnsupported && 'this node version does not support ' + algorithm },
		function (t) {
			vectors.forEach(function (obj, i) {
				var input = new Buffer(obj.input, 'base64');
				var node = obj[algorithm];
				var js = createHash(algorithm).update(input).digest('hex');
				t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node);

				encodings.forEach(function (encoding) {
					var eInput = new Buffer(obj.input, 'base64').toString(encoding);
					var eNode = obj[algorithm];
					var eJS = createHash(algorithm).update(eInput, encoding).digest('hex');
					t.equal(eJS, eNode, algorithm + '(testVector[' + i + '], ' + encoding + ') == ' + eNode);
				});
				input = new Buffer(obj.input, 'base64');
				node = obj[algorithm];
				var hash = createHash(algorithm);
				hash.end(input);
				js = hash.read().toString('hex');
				t.equal(js, node, algorithm + '(testVector[' + i + ']) == ' + node);
			});

			t.end();
		}
	);
}

function testLib(name, createHash) {
	algorithms.forEach(function (algorithm) {
		runTest(name, createHash, algorithm);
	});
}

testLib('createHash in crypto-browserify', require('../').createHash);
testLib('create-hash/browser', require('create-hash/browser'));