@cincel.digital/crypto
v0.10.2
Published
## Description
Downloads
23
Readme
crypto-client
Description
Installation
Usage
Keys generation (CSR and private key)
import {csr} from 'NODE:CINCELcc';
const parmsCSR = {
keys: {
type: 'rsa',
pwd: 'top secret'
},
subject: {
name: 'Nombre de Prueba 1',
email: '[email protected]',
},
};
const resp = new csr().newCSR(parmsCSR);
console.log(`Private key: ${resp.privKey}`);
console.log(`CSR: ${resp.csr}`);
CMS/PKCS7 generation
import {cmsBuilder} from '../src/index.js';
const cert = '-----BEGIN CERTIFICATE----- ...'
const pvK = '-----BEGIN PRIVATE KEY----- ...'
const parmsCMS = {
signer: {
keys: [
{ id: 'cmsLocalKey1', keyInfo: { cert: cert, privK: pvK, pass: 'top secret'}}
]
},
certsACs: [
'-----BEGIN CERTIFICATE----- ...'
]
}
const hAlg = 'sha512';
const hash = 'db051551a8fd08a6df0296b20afbb4ed6d58f7413c4cb593eb01d76d6328dae49130ff452aa783b8787c2c697c78e876753286d5c2fa280ff3865e5ce2a7ab43';
const gen = new cmsBuilder(parmsCMS);
let cms = gen.generateDataSigned(/*externalSignatures*/ true, /*idKey*/ 'cmsLocalKey1', hAlg, hash, /*encode*/ 'PEM');
console.log(`CMS(PEM): ${cms}`);