tcem-rsa
v1.0.9
Published
the package support encrypt data and decrypt data through private key and public key, asymmetric encryption
Downloads
12
Readme
Tcem-rsa
Solution
encrypt data via asymmetric encryption algorithm using public key to encrypt and private key to decrypt
Example
encrypt
encryptStringWithRsaPublicKey function
- param
- data type any
- path publicKey or dafault
const { encryptStringWithRsaPublicKey } = require('tcem-rsa');
const data = 'hi iam tcem';
const cypher = encryptStringWithRsaPublicKey(data);
console.log(cypher);
rbuT3lnpSIdtbQfzw5P61YanhQRZA/mxpFs/lUYWhQ9vQeg+Og9e5Hw8SFxKqsQWPV Qfzw5P61YanhQRZA/mxpFs/lUYWhQ9vQeg+Og9Qfzw5P61YanhQRZA/mxpFs/lUYWhQ9 Qfzw5P61YanhQRZA/mxpFs/lUYWhQ9vQeg+Og9Qfzw5P61YanhQRZA/mxpFs/lUYWhQq
decrypt
decryptStringWithRsaPublicKey function
- param
- data need to be decypt
- path publicKey or dafault
const { decryptStringWithRsaPublicKey } = require('tcem-rsa');
const data = decryptStringWithRsaPublicKey(cypher);
console.log(data);
hi iam tcem
file public key, private key default
publicKey, privateKey function
const { publicKey, privateKey } = required('tcem-rsa)'
console.log(publicKey)
console.log(privateKey)
- log public key
-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr7gC2aulOolczqJ6Asbd GTDQIRBRgFxmyQlSYsqRiNKzljoUM5hpM7yOtdSUjokQ7JGeYRaIrukUShnK8eQG btgjV91/lo6jzdgO6ByMHPOPtOxaLztVpBT/OiCMdx3oZ8M6U5xOzvZA2Ld7Ieya 4h56GqRYjxpTyDvT9lI6MmfJD58+i7YsjJyv5QCzG9QJb9izdLSJ2kVE//ud7CPq cPnlaoqAT0OMTAAVaPkAM4+gWF3QtpfdjYDZNGxNpNt3riMudBFL/SGwCVlc4syT swFP07kTkBcOnd6Qvk1NmVBUri6IxPLTlfl80roHTbPRFr3QfjrVEaT1jmNPyeoN rwIDAQAB -----END PUBLIC KEY-----
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