Questions tagged [crypto]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
0answers
46 views

Does APEX language support ES256 algorithm?

I'm trying to implement social login via Apple. When requesting an access token, I get an "invalid_client" error. I found that one cause for this issue is a bad-formatted JWT, which is ...
-2
votes
0answers
38 views

Problems encrypting and decrypting query string parameters in Visualforce page

I am working on a requirement to securely pass parameters from a visualforce page to another visualforce page hat is hosted on a force.com site. However, I keep on getting one error or the other ...
-1
votes
1answer
60 views

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

I know that Salesforce supports symmetric AES-based encryption(Crypto Class). What if I need to decrypt a message in salesforce which is encrypted using asymmetric RSA?
1
vote
1answer
48 views

Export public key from the certificate

I want to understand if there is a way to export a public key using any crypto methods, the way openssl is generating. I am able to successful generate public key with the following command, however I ...
0
votes
1answer
33 views

How to pass key from an apex class to Visualforce controller class?

I have created a process builder which invokes apex class when a checkbox is true and it adds the encrypted Id and encrypted key to the fields in opportunity records. The issue is that when I am ...
0
votes
0answers
27 views

Import Crypto JS Libraires, Generate Encrypted one and update to DE [duplicate]

Use-case: After FB leads insert into DE, i have to do a encryption on the email address and update the DE to one of the field, I have to use base64encode, HMACSHA256. i am able to retiever records(...
4
votes
1answer
246 views

How Verify HMAC in Salesforce

Any ideas what I am doing wrong? Data = '1605470404trashed'; Private Key = '5034eafbf7068b76e4762db248effd77'; Algoithm: SHA256 Actual HMAC generated from service = ...
1
vote
1answer
116 views

ENS - Signature Verification

I followed the Transactional API Notification Signing steps as mentioned in the document here. And I get following signature key as a response on calling the endpoint /platform/v1/ens-callbacks //...
2
votes
0answers
204 views

AES256 decryption problem with PKCS7 Padding

I have an encrypted token(Encrypted in Java system with AES256 algorithm and PKCS7 padding). when I try to decrypt in SF using crypto class. some of the information is missing from the original token. ...
0
votes
1answer
291 views

Decrypting a PGP File from SFTP Server

Problem The client that I am working with is asking us to encrypt (Using PGP or GPG) files from marketing cloud and insert them onto an SFTP Server. Then, we should create a separate Node JS ...
1
vote
3answers
1k views

How to encrypt text in apex using sha512 algorighm?

I have an urgent business requirement which requires verification of user credentials. We need to encrypt the credentials using sha512 algorithm and then compare it with already encrypted text fields ...
1
vote
0answers
79 views

Is there a way to convert JWK to x.509 cert in Apex salesforce

Is there any way in APEX Salesforce to convert JWK to x.509 cert so that the Crypto class can be used to verify another JWT ?
0
votes
1answer
263 views

Encrypting the password [duplicate]

I have a custom objects which will have user information fields and password fields. Also i have custom LWC (salesforce site) with Username and password. Password has to store in encrypt value. ...
1
vote
1answer
128 views

Payeezy credit card payment integration using HMAC [duplicate]

I was recently working on Payeezy (link) integration with sales force. Payeezy was using HMAC to generate authorization header with help of certain apiKey, Token, TimStamp, Nonce and API Secret key. ...
1
vote
2answers
1k views

SHA256 Algorithm

I have to apply SHA256 algorithm to a string. As the Salesforce document says, I have used the method SHA256('myString', 'UTF-8') and its giving an error as 'Method not exists'
1
vote
1answer
606 views

Crypto.verify(..) - format of a public key

I'm actually using an apex implementation of jwt for the rsa256 cryptography type using this class from github : https://github.com/salesforceidentity/jwt. I have been able to generate a signature ...
3
votes
1answer
949 views

Encryption / decryption with AES

I have an integration with another system which I should use the AES Algorithm.The Encryption is made in SF side - and sent in the header of an HTTP request. This made to recognize SF in internal ...
1
vote
1answer
287 views

Encrypt with Apex and decrypt with OpenSSL - base64 encoding and line breaks

Reposting the post to Salesforce forum from Network security forum: I am encrypting a file with Crypto class and trying to Decrypt in Open SSL and facing issues. The same source file encrypted in ...
3
votes
2answers
1k views

Using the Crypto.verify() method to verify a JWT signature

I am trying to validate a JWT in apex by using the Crypto.verify() method, however, it always returns false despite the fact that I know it is valid. I know it valid because a) I created it and b) I ...
0
votes
1answer
719 views

base64 hash using HMAC SHA256

I am trying to compute the Apex equivalent of the following - var shaBodyContent = CryptoJS.HmacSHA256(stringToSign, postman.getEnvironmentVariable("HMAC_SS")); var b64BodyContent = shaBodyContent....
3
votes
1answer
832 views

Encrypting and/or decrypting ciphertext with the provided Initialization Vector (IV)

I had given an cipher text (of JSON string), an IV and a key. I tried decrypting using Apex Crypto class's method: decryptWithManagedIV(algorithmName, privateKey, IVAndCipherText) //Sample code ...
1
vote
1answer
596 views

How can we encrypt/decrypt AES-GCM (A256GCM) algorithm (i.e. JCA: AES/GCM/NoPadding) in Salesforce?

I am currently working on a requirement where I am developing Apex REST callouts to an external data providers. Here the complexity lies within the encryption/decryption methods that they are using: ...
5
votes
0answers
2k views

Anonymous Crypto method error: last block incomplete in decryption

I am testing some Crypto methods for decryption in the anonymous window. But getting this error while trying with valid inputs: Blob key = Blob.valueOf('xxxxxxxxxxxxxxxx'); System.debug('key: ' +key);...
1
vote
1answer
60 views

How to add a generic method for Encryption and decryption when using multiple times in the code?

I am trying to encrypt two fields when record is submitted using VF page. As there are multiple functions in my class I am encrypting and decrypting multiple times as needed. Is there a way we can ...
0
votes
0answers
1k views

System.SecurityException: last block incomplete in decryption

I'm getting the error when I'm trying to decrypt an encrypted value. Using the standard method from Crypto Class : Encrypt and Decrypt public static String encryptValue(String customKey,String ...
2
votes
2answers
792 views

Generate a JWT with HS256 signature

I am trying to generate an HS256 signed JWT token via Apex. I am using this token in the Authy registration process to enable 2FA for community users. Per the Authy documentation HS256 is the only ...
1
vote
1answer
327 views

Classic Master Encryption Keys in Apex

I'm using the Crypto class but want to leverage the built-in Master Encryption Key store instead of saving my own AES keys somewhere in the database. Is it possible to get access to the Master ...
1
vote
2answers
243 views

Integration that involves encryption

I've done quite a few JSON/REST integrations and only two SOAPs, but this API I'm working with looks like neither. They do offer example code. I stuck with the java example because that is what I've ...
-1
votes
2answers
316 views

AES128: Apex Encryption to Java Decryption Checksum Generation

I am trying to integrate payment gateway into salesforce site, i have used the AES128 Encryption and same is use for decryption but while decryption i have used java code where i got the decrypt value ...
2
votes
1answer
892 views

Is Crypto.generateMac method work exactly the same as Mac and SecretKeySpec java classes

I need to create a signature in order to send a request to CyberSource. I have the following Java code, that works perfectly: String signatureString = "Test"; final Mac sha256HMAC = Mac.getInstance("...
2
votes
0answers
90 views

Creating the signature value of a digital signature “manually”?

I need to sign some xml. The issue is that I cannot use the native Salesforce Crypto.signxml() method because I need to sign the soap:body and place the signature in the soap:header element, and this ...
0
votes
1answer
596 views

convert javascrip function CryptoJS.HmacSHA256() to apex

I am trying to convert the below javascript code into apex. The javascript code is below- timestamp = Math.round((new Date()).getTime() / 1000); var method = request.method; var path = request.url....
0
votes
1answer
71 views

Prevent Duplicates using unique key

We want to prevent duplicate records of a custom object. The key is built from 20 fields of the record, for example: Let's say a record has Name = "Test", Date="01/01/2018", Number="5" the key would ...
0
votes
2answers
1k views

JWT, Cyrpto.Sign and EncodingUtil.base64Encode

I'm writing my own class to create a JWT. Using the JSONGenerator I am creating the header and payload, base64 encoding these with EncodingUtils. I am then creating a blob from these to sign and use ...
0
votes
1answer
196 views

java AES128 And Salesforce Aes128

What can I do to make apex's aes128 encryption result and Java's aes128 encryption result the same, please help me,Here are my apex Aes128 encryption methods and Java Aes128 encryption methods: ...
7
votes
2answers
2k views

MD5 Blob Cannot Convert to String

I'm attempting to generate an MD5 hash in my Apex code and having issues converting the Blob object that Crypto.generateDigest() returns back into a string. The input Blob is a just-Blob.valueOf()-...
2
votes
0answers
171 views

Crypto encrypt with external IV

how can I achieve the same result from the bellow JS to apex? I already have tried: blob encryptedData = Crypto.encrypt('AES128', AesKey, AesIv, json); //apex but it says 'Invalid initialization ...
1
vote
2answers
960 views

Generate random string using Crypto.generateAesKey?

I need to generate an unique alphanumeric string of length of 30 characters which will be used very similar to the record id. Is it okay to use Crypto.generateAesKey() method to generate this 30 ...
1
vote
0answers
339 views

Building a RSA-SHA1 Signature from Apex

I'm trying to sign a request from apex using RSA-SHA1 algorithm. I'm following the Amazon web service requirements to build the signature as i'm actually generating a cloudfront signed url. The ...
9
votes
1answer
2k views

Canvas app - verify signed request

i am following the canvas app documentation to verify a signed request before using the parameters i am passing in the canvas app request. The canvas app is embedding a third party app in salesforce. ...
1
vote
2answers
266 views

SHA256 breaking personalization strings in email

We are currently using this code block in an email %%[ VAR @email, @customer_no, @secret, @url, @hash SET @email = "%%email%%" SET @customer_no = "%%customer_no%%" SET @secret = "<secretkey>" ...
1
vote
1answer
250 views

Symmetrically encrypt data off Salesforce and decrypt in Apex?

We want to encrypt data generated in a Ruby on Rails app to be encrypted, passed to Salesforce, and then be decrypted in Apex code. This seems like a clear case for using Crypto.decrypt: decrypt(...
0
votes
0answers
664 views

Apex crypto class to encrypt REST API

We are using angular for front-end and Salesforce is being used for maintaining database. REST APIs have been written on Salesforce to communicate and fetch data to front-end. A custom profile has ...
-2
votes
1answer
335 views

Convert Java encryption code to Apex

I would like to translate this method into java for apex. Tried in different ways and could not :/ public static String encodeString(String stringToEncode, String secret) throws Exception { byte[]...
2
votes
0answers
312 views

Unable to get a valid signature using APEX Crypto.signXml()

I am trying to sign an XML with the APEX method Crypto.signXml(), but I am not able to obtain a valid signature. I'm developing in Salesforce an integration with an external SOAP Web Service that ...
2
votes
0answers
86 views

Crypto sign string using DSA private key in Salesforce

Colleagues, I'm doing integration using REST API with a service that requires a string signed by private key which uses DSA algorithm. The problem is in APEX Crypto class does not support DSA keys (...
0
votes
1answer
294 views

How do I get value of Tenant Secret Key by Apex Code?

My manager claims that Salesforce has very weak and limited support of cryptography and encryption. I want to disprove this statement and prove that we could, for example, implement some custom ...
-1
votes
1answer
203 views

Encrypt json file while sending it to External System

i have custom object with the json file attached in it. i need to encrypt it while sending this file to external system. how can i achieve this in sfdc
0
votes
2answers
5k views

How to generate a 32 byte private key?

I am facing an issue while using the crypto class of salesforce Below is the code snippet: Blob cryptoKey = Crypto.generateAesKey(128); System.debug('KeyBlobSize:-'+cryptoKey.size()); System.debug('...
1
vote
0answers
105 views

Help Converting a Java Crypto class over to Apex Crypto

I have a java class for generating a token and I am struggling on converting it to apex. Below is the code. Any pointers would be appreciated! Here are the two methods in the java class that get ...