
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
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 593 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’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.