gpg AES encryption Apex decryption

2019-08-30 00:02发布

问题:

I'm new to encryption and have the requirement to encrypt a csv file on Linux OS and decrypt the file in Salesforce using AES algorithm.

I have shared the key from Salesforce to encrypt the file generated by calling generateAesKey() as below:

Blob cryptoKey = Crypto.generateAesKey(128);
System.debug('>>>>>CryptoKey'+ cryptoKey);

String readableKey = EncodingUtil.base64Encode(cryptoKey);
System.debug('>>>>>Readable Key  ' + readableKey);

**Shared Key**
1qoG9koNWzLBLAqjazP24g==

Using the key shared in email, other team are trying to encrypt the file.

gpg --output test.csv.pgp --symmetric --cipher-algo AES test.csv

I think there is something wrong with the way they are encrypting as the key shared is being used as passphrase. Please guide.

I am aware of the functions in Apex used for decryption but I highly doubt if the source system is encrypting file correctly.

Blob decryptedData = Crypto.decryptWithManagedIV('AES128', key, encData);

System.Debug( decryptedData.toString() );