
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
cryptography
Advanced tools
Simplified functions for nodejs cryptography.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>options.callback <Function>
Returns a promise which is resolved with encrypted string. If a callback is passed it is called with encrypted string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>Synchronous encrypt(). Returns encrypted string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>options.callback <Function>
Returns a promise which is resolved with decrypted string. If a callback is passed it is called with decrypted string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>Synchronous decrypt(). Returns decrypted string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>options.callback <Function>
Returns a promise which is resolved with hashed string. If a callback is passed it is called with hashed string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>Synchronous hmac(). Returns hashed string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>options.callback <Function>
Returns a promise which is resolved with hashed string. If a callback is passed it is called with hashed string.
options <Object> | <string>options.key <string>options.algorithm <string>options.encoding <string>options.data <string>Synchronous hash(). Returns hashed string.
options <Object> | <Number>options.size <Number>options.encoding <string>options.callback <Function>
Returns a promise which is resolved with random bytes string. If a callback is passed it is called with random bytes string.
Synchronous randomBytes(). Returns random bytes string.
const cryptography = require("cryptography");
// Set defaults
cryptography.defaults.key = "password";
cryptography.defaults.encryptionAlgorithm = "aes192";
cryptography.defaults.encoding = "hex";
// Use defaults
cryptography.encrypt("string to encrypt")
.then(function(encrypted)
{
return cryptography.decrypt(encrypted);
})
.then(function(decrypted)
{
console.log(decrypted) // outputs: "string to encrypt"
})
.catch(function(error)
{
// An error occurred
});
// Override defaults for one call
cryptography.encrypt({
key: "another password",
data: "string to encrypt"
})
.then(function(encrypted)
{
return cryptography.decrypt({
key: "another password",
data: encrypted
});
})
.then(function(decrypted)
{
console.log(decrypted) // outputs: "string to encrypt"
})
.catch(function(error)
{
// An error occurred
});
const cryptography = require("cryptography");
var decryptCallback = function(error, decrypted)
{
if(error)
{
// Error occurred
return;
}
console.log(decrypted);
};
var encryptCallback = function(error, encrypted)
{
if(error)
{
// Error occurred
return;
}
cryptography.decrypt({
data: encrypted,
callback: decryptCallback
});
};
cryptography.encrypt({
data: "string to encrypt",
callback: encryptCallback
});
const cryptography = require("cryptography");
try
{
var encrypted = cryptography.encryptSync("string to encrypt");
var decrypted = cryptography.decryptSync(encrypted);
}
catch(error)
{
// Error occurred
return;
}
console.log(decrypted);
FAQs
Simplified functions for nodejs cryptography.
The npm package cryptography receives a total of 382 weekly downloads. As such, cryptography popularity was classified as not popular.
We found that cryptography 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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.