padding is inavalid and cannot be removed error how to fix this
while iam encrypting json using online tool while that encrypted value and key used in outsystems to decrypt json this error getting what does meant?
Hi Pydisetti,
what type of online tool are you using?
Regards,
Dhivyaraj Sivam
while i used to encrypt string and decrypt in outystems it getting good while i tried to encrypt json and trying to decrypt getting error
tool links :
https://www.devglan.com/online-tools/aes-encryption-decryption
https://www.javainuse.com/aesgenerator
from these two links getting that error while i decrypting json why? is it my fault
i uses aes encryption service not crypto api in outystems
Is the same secret key used to encrypt and decrypt?
yes can i post
getting same error can u tried once
Please share your OML file.
padding is invalid and cannot be removed getting for json files can u once check it
where using another website it working properly can u write encryption code for this?
I have implemented OML for encrypting and decrypting, which I believe will be useful to you.
hi Pydisetti,
You can use cipher mode as "CBC" in online tool https://www.devglan.com/online-tools/aes-encryption-decryption to decrypt your value, as AesOperations using this mode for encryption and decryption of data. if you just want to test online.
here intilization vector is optional while implementing code and using that it getting same error how to fix intilization vector in aes operations can u plz tell or can we write code in cbc with out using intlization vector
Yes, you can use it without passing initialization vector, as shown in screenshot.
how to write code for encryption with out using intilization vector is it mandatory in cbc right
You can write code for encryption without using IV ( initialization vector). the library used in extension provide the default value for IV internally.
I hope this answers your question.
const crypto = require('crypto');
function encrypt(plaintext, key) {
const cipher = crypto.createCipher('aes-256-cbc', key);
let encrypted = cipher.update(plaintext, 'utf8', 'hex');
encrypted += cipher.final('hex');
return encrypted;
}
function decrypt(encryptedData, key) {
const decipher = crypto.createDecipher('aes-256-cbc', key);
let decrypted = decipher.update(encryptedData, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
// Example usage
const data = {
message: "secret message"
};
const plaintext = JSON.stringify(data);
const key = crypto.randomBytes(32).toString('hex');
const encrypted = encrypt(plaintext, key);
const decrypted = decrypt(encrypted, key);
console.log(plaintext === decrypted);
i use this code but getting same error
plz check it
while decrypting getting this like in starting
@Pydisetti sai Any luck?
I think that the issue is happening when the size of encrypted size increasing. For example, if you encrypt a 15 character length text using the online tool and try to decrypt it using the extension, then it is success. But, if the encrypted text length is greater than 15, then we are getting the error related to padding.