Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

md5-base64

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

md5-base64 - npm Package Compare versions

Comparing version
0.0.1
to
0.0.2
+9
-65
index.js

@@ -1,74 +0,18 @@

#! /usr/bin/env node
'use strict';
/*
* TRAWLER-STD (entry point).
* MD5-BASE64
*/
const packageJSON = require('./package.json');
const appPackageJSON = require('./modules/appPackageJSON');
const extender = require('object-extender');
const TrawlerStd = require('./TrawlerStd');
const crypto = require('crypto');
// Prepare Trawler.
const boat = new TrawlerStd({
app: {
name: appPackageJSON.name,
version: appPackageJSON.version,
mainFile: appPackageJSON.main,
env: process.env.NODE_ENV,
},
trawler: extender.copy(appPackageJSON.trawler) || {}, // Break the reference with the app's packageJSON object.
cliArgs: process.argv.slice(2),
});
module.exports = function (input) {
function processExitOnException (code) {
boat.log.debug('Goodbye.');
process.exit(code || 1);
}
// Create the algorithm.
const algo = crypto.createHash('md5');
// Ensure we throw exceptions that occur within Trawler rather than swallowing them.
// We bind this method to 'boat' (the Trawler instance) below.
function handleUncaughtException (unhandledErr) {
// Create the base64 encoded hash.
algo.update(input);
return algo.digest('base64');
// Output the unhandled error and add a timer to force quit the app if we get stuck in an error loop.
boat.log.error(unhandledErr.stack);
setTimeout(processExitOnException.bind(null, 1), 3000); // Prevent error loops.
// Log the Trawler crash.
boat.outputLog('trawler', {
message: `Trawler (v${packageJSON.version}) itself has crashed!`,
trawlerLogType: 'error',
}, () => { // Ignore any error here.
// Attempt to notify our services.
boat.sendNotifications({
notificationType: 'trawler-crash',
trawlerErr: unhandledErr,
}, () => { // Ignore any error here.
// Crash Trawler with the unhandled error.
setTimeout(processExitOnException.bind(null, 1), 1000); // Slight delay to allow streams to flush.
});
});
}
process.on('uncaughtException', handleUncaughtException);
// Initialise Trawler instance.
boat.init((err) => {
if (err) { throw err; }
// Ensure we tidy up the child app when Trawler quits.
process.on('SIGINT', () => {
console.log(''); // Line break after the ^C in the console.
process.exit(0); // When ctrl-c is pressed.
});
process.on('exit', () => {
boat.killApp();
});
});
};
+2
-4

@@ -10,3 +10,3 @@ {

"name": "md5-base64",
"version": "0.0.1",
"version": "0.0.2",
"description": "Quickly create MD5 hashes encoded as base64 strings.",

@@ -37,5 +37,3 @@ "keywords": [

},
"dependencies": {
},
"dependencies": {},
"license": "MIT",

@@ -42,0 +40,0 @@ "engines": {

@@ -1,2 +0,16 @@

# md5-base64
# MD5 Base64
Quickly create MD5 hashes encoded as base64 strings.
## Install
```
npm install --save md5-base64
```
## Usage
```javascript
const md5Base64 = require('md5-base64');
const hash = md5Base64('my-plain-text-string');
```