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

@bscotch/utility

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bscotch/utility - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

8

build/lib/crypto.d.ts

@@ -7,2 +7,10 @@ /// <reference types="node" />

export declare function md5(source: BinaryLike, encoding?: Encoding): Buffer & string;
/**
* Create a strong encryption of some source data using AES256-CBC
*/
export declare function encrypt(text: string | Buffer, key: string): string;
/**
* Decrypt something encrypted using the sibling 'encrypt' function.
*/
export declare function decrypt(encryptionString: string, key: string): Buffer;
//# sourceMappingURL=crypto.d.ts.map

29

build/lib/crypto.js

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.md5 = exports.sha256 = exports.sha1 = exports.createHash = void 0;
exports.decrypt = exports.encrypt = exports.md5 = exports.sha256 = exports.sha1 = exports.createHash = void 0;
const crypto_1 = __importDefault(require("crypto"));
const errors_1 = require("./errors");
function createHash(algorithm, source, encoding = "hex") {

@@ -29,2 +30,28 @@ return crypto_1.default

exports.md5 = md5;
const ivLength = 16; // required for AES
const encoding = 'base64';
const algorithm = 'aes-256-cbc';
/**
* Create a strong encryption of some source data using AES256-CBC
*/
function encrypt(text, key) {
errors_1.assert(key.length == 32, 'Key must be length 32');
const iv = crypto_1.default.randomBytes(ivLength);
const cipher = crypto_1.default.createCipheriv(algorithm, key, iv);
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
return `${iv.toString(encoding)}:${encrypted.toString(encoding)}`;
}
exports.encrypt = encrypt;
/**
* Decrypt something encrypted using the sibling 'encrypt' function.
*/
function decrypt(encryptionString, key) {
errors_1.assert(key.length == 32, 'Key must be length 32');
const [iv, encrypted] = encryptionString.split(':')
.map(string => Buffer.from(string, encoding));
const decipher = crypto_1.default.createDecipheriv(algorithm, Buffer.from(key), iv);
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
return decrypted;
}
exports.decrypt = decrypt;
//# sourceMappingURL=crypto.js.map

4

build/lib/files.d.ts

@@ -29,3 +29,5 @@ export interface ListPathOptions {

*/
export declare function removeEmptyDirsSync(startDir: string): void;
export declare function removeEmptyDirsSync(startDir: string, options?: {
excludeRoot?: boolean;
}): void;
//# sourceMappingURL=files.d.ts.map

@@ -77,7 +77,7 @@ "use strict";

*/
function removeEmptyDirsSync(startDir) {
const folders = [
startDir,
...listFoldersSync(startDir, true)
];
function removeEmptyDirsSync(startDir, options) {
const folders = listFoldersSync(startDir, true);
if (!(options === null || options === void 0 ? void 0 : options.excludeRoot)) {
folders.unshift(startDir);
}
folders.reverse();

@@ -84,0 +84,0 @@ for (const folder of folders) {

/** Get a promise that resolves in some number of milliseconds. */
export declare function resolveInMillis(millis: number): Promise<unknown>;
export declare function resolveInMillis(millis: number): Promise<void>;
/** Get a promise that resolves in some number of seconds. */
export declare function resolveInSeconds(seconds: number): Promise<unknown>;
export declare function resolveInSeconds(seconds: number): Promise<void>;
export declare function resolveInNextTick(): Promise<unknown>;
export declare function wait(millis: number): Promise<void>;
//# sourceMappingURL=wait.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveInNextTick = exports.resolveInSeconds = exports.resolveInMillis = void 0;
exports.wait = exports.resolveInNextTick = exports.resolveInSeconds = exports.resolveInMillis = void 0;
/** Get a promise that resolves in some number of milliseconds. */

@@ -18,2 +18,6 @@ function resolveInMillis(millis) {

exports.resolveInNextTick = resolveInNextTick;
function wait(millis) {
return resolveInMillis(millis);
}
exports.wait = wait;
//# sourceMappingURL=wait.js.map

@@ -0,1 +1,10 @@

# [0.11.0](https://github.com/bscotch/node-util/compare/v0.10.0...v0.11.0) (2021-01-27)
### Features
* Add simple encrypt/decrypt functions. ([9887240](https://github.com/bscotch/node-util/commit/98872409d5cd87667ba116f0a9c9173014da5019))
# [0.10.0](https://github.com/bscotch/node-util/compare/v0.9.1...v0.10.0) (2021-01-27)

@@ -2,0 +11,0 @@

{
"name": "@bscotch/utility",
"version": "0.10.0",
"version": "0.11.0",
"description": "Bscotch Utilities: Methods for common Node.js needs.",

@@ -5,0 +5,0 @@ "engines": {

@@ -201,2 +201,4 @@ # Bscotch Utilities

createHash,
encrypt,
decrypt,
} from '@bscotch/utility';

@@ -207,2 +209,6 @@

hash = createHash('sha1','hello world');
const key = "00000000000000000000000000000000";
const encrypted = encrypt("Hello World",key);
const sourceAsBuffer = decrypt(encrypted,key);
```

@@ -209,0 +215,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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