cifrado-rsa-sha256
v0.0.4
Published
Libreria para el cifrado y descifrado con el algoritmo RSA/ECB/OAEPWithSHA-256AndMGF1Padding
Downloads
66
Readme
RSA-SHA256
Project for the encryption and decryption of information using the RSA algorithm with keys of size 256.
Installation
Install cifrado-rsa-sha256 with npm
npm i cifrado-rsa-sha256
Once the package is installed, you can import the library using import or require approach:
const sha256 = require("cifrado-rsa-sha256");
Examples
const sha256 = require("cifrado-rsa-sha256");
let llavePublica = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3YxExr3qrmKVpNB+QsSAXv/lBrKVI17UNr5WzxGQABEpo1ke+iOD/3CcCegwpto8OF/hDwESb66ZEgF5kW6e5fT7S9Udy0J36iU7It5OABmBtOmikYsn/V1i3MU6ZAaEJ1akv+8uMWOIHehcgwzFETzoq7Sl8gqwqS2Zi6YA/D1fkA+rq39hE2hW8f8SUf4KqwHWUA3J1sLA3BbjcxOMLsXevCAxkVUgeXbpcNoc2MmoPShAy6uPs2pGMGWxvDTzr3uBfUDbjwkyeL+tpVfkoDxzB/X+1S8q7Xq3qL7KeOsUmOZ5/pHVC20btQvDOrhm9WtyKUNasvSus678yvGP0QIDAQAB'
let llavePrivada = 'MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDdjETGvequYpWk0H5CxIBe/+UGspUjXtQ2vlbPEZAAESmjWR76I4P/cJwJ6DCm2jw4X+EPARJvrpkSAXmRbp7l9PtL1R3LQnfqJTsi3k4AGYG06aKRiyf9XWLcxTpkBoQnVqS/7y4xY4gd6FyDDMURPOirtKXyCrCpLZmLpgD8PV+QD6urf2ETaFbx/xJR/gqrAdZQDcnWwsDcFuNzE4wuxd68IDGRVSB5dulw2hzYyag9KEDLq4+zakYwZbG8NPOve4F9QNuPCTJ4v62lV+SgPHMH9f7VLyrtereovsp46xSY5nn+kdULbRu1C8M6uGb1a3IpQ1qy9K6zrvzK8Y/RAgMBAAECggEAAW0zzCvQ5QqRe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ctoaniPxl6m8zrPHY8iSTh+vj75tvLXoMM1HoyCMJykxWQ3WVCGmalduu/yp2c42Hx5spGXQOwZwT7R2soUanl6FUYlFO3hV87fEtI6ZPWZvc/YhPMWRTQeaiW1jMOP0cEBP';
const docBusq = {
idDocumento: 9300,
idUsuario: sha256.encrypt('1016027',llavePublica),
idEmpresa: 1,
numeroPagina: 1,
registrosPorPagina: 5
};
console.log(`El dato cifrado es: ${JSON.stringify(docBusq)}`);
docBusq.idUsuario = sha256.decrypt(docBusq.idUsuario,llavePrivada);
console.log(`Dato en claro: ${JSON.stringify(docBusq)}`);