
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Node module that provides cryptographic functionalities using crypto
for ciphering and bcrypt
for encryption.
In your project root run from command line:
$ npm install -save crypton
Let's start! Include in your node application crypton
module:
//require object
var Crypton = require('crypton').Crypton;
//or require factory
var factory = require('crypton');
//create options
var options = {
crypto: {
secretKey: 'o!rDE(Qbrq7u4OV',
algorithm: 'AES-256-CBC',
inputEncoding: 'utf8',
outputEncoding: 'base64'
},
bcrypt: {
saltRounds: 5
}
};
//create an instance
var cryptoManager1 = new Crypton(options);
//or use factory
var cryptoManager2 = factory.create(options);
cryptoManager1.cipher('mytext')
.then(function(res) {
console.log(res);
});
A Crypton
instance can be created using factory or using the new
keyword.
var factory = require('crypton');
var cryptonManager1 = factory.create();
//or
var Crypton = require('crypton').Crypton;
var cryptonManager2 = new Crypton();
The crypton
module can be initialized with a configuration object.
Arguments
[options] {Object} Optional configuration
Returns
{Object} Get an instance
The configuration object allows you to overrides default values. If you don't specify any configuration, it uses a default object:
{
crypto: {
secretKey: 'o!rDE(Qbrq7u4OV',
algorithm: 'AES-256-CBC',
inputEncoding: 'utf8', //utf8|base64|hex
outputEncoding: 'base64' //utf8|base64|hex
},
bcrypt: {
saltRounds: 5 //the cost of processing the data
}
}
Cipher a text with crypto. The operation is reversible. Options param could be the entire crypto configuration or only an attribute:
{
secretKey: 'o!rDE(Qbrq7u4OV'
}
Arguments
text {string} Text to cipher
[options] {object} Overrides configuration
Returns
{string} Returns the ciphered text
Throws
{CipherCryptonError}
Decipher a ciphered text with crypto. Options param could the entire crypto configuration or only an attribute:
{
secretKey: 'o!rDE(Qbrq7u4OV'
}
Arguments
text {string} Text to decipher
[options] {object} Overrides configuration
Returns
{string} Returns the deciphered text
Throws
{DecipherCryptonError}
Crypt a text with bcrypt. The operation is not reversible. Options param could the entire bcrypt configuration or only an attribute:
{
saltRound: 10
}
Arguments
text {string} Text to crypt
[options] {object} Overrides configuration
Returns
{string} Returns the crypted text
Throws
{EncryptCryptonError}
Check if the clear text matches with the ciphered text. If force is specified it accepts two ciphered strings to compare. Use this method only with ciphered text. Options param could the entire crypto configuration or only an attribute:
{
secretKey: 'o!rDE(Qbrq7u4OV'
}
Arguments
text {string} Text to compare with ciphered
ciphered {string} Ciphered text
force {bool} Force the compare
[options] {object} Overrides configuration
Returns
{bool} Returns the result of the match
Throws
{CompareCryptonError}
Check if the clear text matches with the crypted text. Use this method only with crypted text.
Arguments
text {string} Text to compare with crypted
crypted {string} Crypted text
Returns
{bool} Returns the result of the match
Throws
{VerifyCryptonError}
Get md5 hash of a given string.
Arguments
text {string} Text to hash
Returns
{string} Returns md5sum in hex format
Throws
{Md5CryptonError}
Get random bytes.
Arguments
len {int} Bytes length
Returns
{string} Returns bytes in hex format
Throws
{RandomBytesCryptonError}
The MIT License
Copyright (c) 2017 Michele Andreoli http://thinkingmik.com
FAQs
Node module that provides cryptographic functionalities
We found that crypton demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.