
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
The triplesec npm package is a high-level cryptographic library that provides encryption, decryption, and hashing functionalities. It is designed to be easy to use and secure, combining multiple cryptographic algorithms to enhance security.
Encryption
This feature allows you to encrypt data using a specified key. The code sample demonstrates how to encrypt a simple plaintext message.
const triplesec = require('triplesec');
const plaintext = Buffer.from('Hello, World!');
const key = Buffer.from('mysecretkey');
triplesec.encrypt({ key: key, data: plaintext }, function(err, buff) {
if (!err) {
console.log('Encrypted:', buff.toString('hex'));
}
});
Decryption
This feature allows you to decrypt data that was previously encrypted using the same key. The code sample shows how to decrypt an encrypted message.
const triplesec = require('triplesec');
const encryptedData = Buffer.from('...'); // Encrypted data in hex format
const key = Buffer.from('mysecretkey');
triplesec.decrypt({ key: key, data: encryptedData }, function(err, buff) {
if (!err) {
console.log('Decrypted:', buff.toString());
}
});
Hashing
This feature allows you to generate a cryptographic hash of the given data. The code sample demonstrates how to hash a simple message.
const triplesec = require('triplesec');
const data = Buffer.from('Hello, World!');
triplesec.hash({ data: data }, function(err, buff) {
if (!err) {
console.log('Hash:', buff.toString('hex'));
}
});
CryptoJS is a widely-used library that provides a variety of cryptographic algorithms for encryption, decryption, and hashing. It is similar to triplesec in terms of functionality but offers a broader range of algorithms and is more actively maintained.
Stanford Javascript Crypto Library (SJCL) is a robust library for cryptographic operations. It is designed to be secure and efficient, similar to triplesec, but it is more focused on performance and security for web applications.
Node-forge is a comprehensive library for implementing various cryptographic operations in Node.js. It offers similar functionalities to triplesec, including encryption, decryption, and hashing, but also includes additional features like SSL/TLS and PKI.
A CommonJS module for symmetric key encryption of smallish secrets
npm install triplesec
{encrypt, decrypt} = require 'triplesec'
key = new Buffer 'top-secret-pw'
pt0 = new Buffer 'the secret!'
pt1 = new Buffer pt0
encrypt { key, data : pt1 }, (err, ciphertext) ->
decrypt { key, data : ciphertext }, (err, pt2) ->
console.log "Right back the start! #{pt0} is #{pt2}"
The most expensive part of TripleSec is to derive keys from your given passphrase. This is intentionally so to make it more expensive to crack your password in the case that your ciphertext is stolen. However, you can spread this expense over multiple encryptions if you plan to be encrypting more than once:
{Encryptor, Decryptor} = require 'triplesec'
key = new Buffer 'top-secret-pw'
enc = new Encryptor { key }
dec = new Decryptor { key }
pt0 = new Buffer 'the secret!'
pt1 = new Buffer pt0
pt2 = new Buffer pt0
enc.run { data : pt1 }, (err, ct1) ->
enc.run { data : pt2 }, (err, ct2) ->
dec.run { data : ct1 }, (err, pt3) ->
dec.run { data : ct2 }, (err, pt4) ->
console.log "Right back the start! #{pt0} is #{pt3} is #{pt4}"
If you want to resalt derived keys with every encryption, you should explicitly ask for that. Otherwise, salt will be reused to speed up encryption (and decryption).
enc.run { data : pt1 }, (err, ct1) ->
enc.resalt {}, () ->
enc.run { data : pt2 }, (err, ct2) ->
4.0.3 (2019-02-01)
FAQs
A CommonJS-compliant system for secure encryption of smallish secrets
The npm package triplesec receives a total of 0 weekly downloads. As such, triplesec popularity was classified as not popular.
We found that triplesec 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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.