You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using BlueEcc for prime256v1 ecnryption and both in iOS and on Node.js server!
I encrypt data in iOS and pass it to Node.js server in base64 form. I am passing both base64 encrypted data and buffer data but receive error.
It doesn't decrypt data COMING FROM IOS SIDE, same for the other way.
I receive the following error!
nternal/crypto/cipher.js:172
const ret = this[kHandle].final();
^
Error: Unsupported state or unable to authenticate data
at Decipheriv.final (internal/crypto/cipher.js:172:29)
at Object.module.exports.decrypt (/Users/yasiriqbal/Desktop/encryption/index.js:114:62)
at Object. (/Users/yasiriqbal/Desktop/encryption/app.js:21:19)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
let privateKeyString = "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEILaJOS3gzq30ub5QL0R3RSDCAeds+HHXNwbtpeJbGPR9oAoGCCqGSM49\nAwEHoUQDQgAEBAGv/eKV+rRnPJEmdT7PIE3iTGityqzxn8lCqVQ+reVLtrc+3c0Q\n0eSP7V19XtDgnjYzzX48T39u64QZ8gpt9A==\n-----END EC PRIVATE KEY-----"
let privateKeyBuffer = Buffer.from( ecc.extractKeyData(privateKeyString, "pem", false), 'base64');
let publicKeyString = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBAGv/eKV+rRnPJEmdT7PIE3iTGit\nyqzxn8lCqVQ+reVLtrc+3c0Q0eSP7V19XtDgnjYzzX48T39u64QZ8gpt9A==\n-----END PUBLIC KEY-----"
let publicKey = Buffer.from( ecc.extractKeyData(publicKeyString, "pem", false), 'base64');
/*
let input = "yasir iqbal"
let encData = ecc.encrypt(publicKey, input);
*/
let encData = "BFU+yKJUjrb9qXdp2jsj+RDqBZbehyBmieX8M4imHWcxy0FvtaynTWRJy8ijAKBMHZCwcbYyt6UsrwLfFXkSG8W+oVI9k6G9zE/6bu0n5Ezif/gs6UIiG39Vq3M="
let base8Buffer = Buffer.from(encData, "base64");
console.log("Enc Data: ", encData);
let decData = ecc.decrypt(privateKeyBuffer, base8Buffer);
console.log("Decrypt Data: ", decData);
Your help would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered:
I am using BlueEcc for prime256v1 ecnryption and both in iOS and on Node.js server!
I encrypt data in iOS and pass it to Node.js server in base64 form. I am passing both base64 encrypted data and buffer data but receive error.
It doesn't decrypt data COMING FROM IOS SIDE, same for the other way.
I receive the following error!
nternal/crypto/cipher.js:172
const ret = this[kHandle].final();
^
Error: Unsupported state or unable to authenticate data
at Decipheriv.final (internal/crypto/cipher.js:172:29)
at Object.module.exports.decrypt (/Users/yasiriqbal/Desktop/encryption/index.js:114:62)
at Object. (/Users/yasiriqbal/Desktop/encryption/app.js:21:19)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
This is my server code!
const ecc = require('./index');
const ECKey = require("ec-key");
let privateKeyString = "-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEILaJOS3gzq30ub5QL0R3RSDCAeds+HHXNwbtpeJbGPR9oAoGCCqGSM49\nAwEHoUQDQgAEBAGv/eKV+rRnPJEmdT7PIE3iTGityqzxn8lCqVQ+reVLtrc+3c0Q\n0eSP7V19XtDgnjYzzX48T39u64QZ8gpt9A==\n-----END EC PRIVATE KEY-----"
let privateKeyBuffer = Buffer.from( ecc.extractKeyData(privateKeyString, "pem", false), 'base64');
let publicKeyString = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBAGv/eKV+rRnPJEmdT7PIE3iTGit\nyqzxn8lCqVQ+reVLtrc+3c0Q0eSP7V19XtDgnjYzzX48T39u64QZ8gpt9A==\n-----END PUBLIC KEY-----"
let publicKey = Buffer.from( ecc.extractKeyData(publicKeyString, "pem", false), 'base64');
/*
let input = "yasir iqbal"
let encData = ecc.encrypt(publicKey, input);
*/
let encData = "BFU+yKJUjrb9qXdp2jsj+RDqBZbehyBmieX8M4imHWcxy0FvtaynTWRJy8ijAKBMHZCwcbYyt6UsrwLfFXkSG8W+oVI9k6G9zE/6bu0n5Ezif/gs6UIiG39Vq3M="
let base8Buffer = Buffer.from(encData, "base64");
console.log("Enc Data: ", encData);
let decData = ecc.decrypt(privateKeyBuffer, base8Buffer);
console.log("Decrypt Data: ", decData);
Your help would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered: