Skip to main content
7 votes

How can I encrypt a string in Apex in a way that an external system can decrypt using C#?

David is absolutely right and I'd like to add some extra information and provide code examples regarding Apex-encryption/C#-decryption. To encrypt some String in Apex using the AES256-CBC algorithm ...
Oleh Berehovskyi's user avatar
7 votes
Accepted

How decrypt MD5

By it's very nature you cannot decrypt MD5. It's a one way hash algorithm. There are some sites that claim to decrypt certain phrases but all they do is store known phrases to return them. Reference ...
gNerb's user avatar
  • 9,510
6 votes
Accepted

Encryption and Decryption in apex Salesforce Using Crypto Class

The following code works in my org. Blob key = Crypto.generateAesKey(256); Blob source = Blob.valueOf('Hello World'); Blob encrypted = Crypto.encryptWithManagedIV('AES256', key, source); String ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

Decryption is throwing System.SecurityException error in apex class

You're generating a random key every time the method is called. In order for the decryption to be successful, you need to use the same key instead. You should store this key either in a custom setting ...
sfdcfox's user avatar
  • 497k
4 votes
Accepted

Marketing Cloud, Decode qs URL Parameter in Cloudpage

There is no need to apply explicit decryption method on QS. When linking to a Cloud Page using CloudPagesUrl function, email address and other parameters are automatically passed and can be retrieved ...
Lukas Lunow's user avatar
  • 21.7k
4 votes

How can I encrypt a string in Apex in a way that an external system can decrypt using C#?

The data I would think an external systems developer would need are: The algorithm: AES256. The cipher mode: Cipher Block Chaining (CBC), as documented for the Apex Crypto class. The padding mode: ...
David Reed's user avatar
  • 93.2k
3 votes

Is it possible to decrypt a message in APEX using asymmetric RSA algorithm?

You can only decrypt symmetric AES-based encryption. RSA is only used for digital signatures (Crypo.sign and Crypto.verify methods).
sfdcfox's user avatar
  • 497k
3 votes
Accepted

Verify POST messages signed with SHA1 in Apex

Looks like this webhook is using an HMAC (a form of Message Authentication Code) for validation. The message technically isn't encrypted; it's combined with a shared secret that you establish and then ...
David Reed's user avatar
  • 93.2k
3 votes

How to decrpt the MCRYPT_RIJNDAEL_256 encrypted value in salesforce.

The AES specification uses a subset of the Rijndael algorithm, so 'AES-256' should be synonymous with 'Rijndael-256' (assuming that the '256' is the size of the key, not the block size. If Rijndael-...
Derek F's user avatar
  • 62.7k
2 votes

Related to Digital signiature

Apex class for capturing the sign public class signAccountExtension { Id accountId; public string fileData { get; set; } public signAccountExtension(ApexPages.StandardController ...
SFDC's user avatar
  • 668
2 votes
Accepted

AES128 decryption. Invalid private key. Must be 16 bytes

You need to use EncodingUtil.convertFromHex to get the correct 16 bytes: Blob keyB = EncodingUtil.convertFromHex('75ac5e7677e7218a7f059f0bda073a6b');
sfdcfox's user avatar
  • 497k
2 votes
Accepted

Encryption / decryption with AES

See Encrypting and/or decrypting ciphertext with the provided Initialization Vector (IV) You didn't describe your needs very well. You said this made to recognize SF in internal services which won't ...
identigral's user avatar
  • 7,691
2 votes

Decrypt an encrypted string using SFDC certificate

You can't do that with keys managed via Certificates and Key Management. Crypto.decrypt(...) supports several symmetric-key AES algorithms. When you encrypt plaintext off SF platform with a key, the ...
identigral's user avatar
  • 7,691
2 votes
Accepted

AES128: Apex Encryption to Java Decryption Checksum Generation

I see several issues or potential issues here. Blob exampleIv = Blob.valueOf('Example of IV123'); This is definitely wrong. In Java, you have hard-coded an initialization vector as a byte string: ...
David Reed's user avatar
  • 93.2k
2 votes
Accepted

AMPScript AES Encrypted and Decrypt with Crypto Apex Class

Finally I found a solution. MKCloud AMPScript's default AES implementation is based on a 256 bit key size, CBC with 16 byte block size, and PKCS7 with 1000 iterations. The derived Key generation is ...
Jaume Bonet's user avatar
1 vote

How to decrypt an encrypted incoming webhook payload

Data is a base-64 encoded string, and the secret key appears to be a 256-bit private symmetric key (just guessing, based on the length). As such, you're going to need to first use EncodingUtil....
sfdcfox's user avatar
  • 497k
1 vote

Marketing Cloud - Decrypt File - "Secret key not found in key data"

This was a passphrase issue. We had to remove some of the special characters we included in the passphrase and the decryption worked in the File Transfer step.
Aaron Gramlich's user avatar
1 vote

Decrypting a PGP File from SFTP Server

I was able to figure out a solution to this using OpenPGP. I read a little bit more into their documentation and tried a couple different things I saw from their solutions. I read the file in using fs....
Neal Matta's user avatar
1 vote

Decrepyt Password Field

This code doesn't really make sense. It looks like you have a field Customer_Community_Details__c.Password1__c that's stored as a Base64-encoded, AES-encrypted blob. Presumably this means your org has ...
David Reed's user avatar
  • 93.2k

Only top scored, non community-wiki answers of a minimum length are eligible