Questions tagged [crypto]
The crypto tag has no usage guidance.
128
questions
-1
votes
0
answers
31
views
Encrypt LWC form data using CryptoJS
As part of Hacker one test findings- We got a requirement to encrypt the LWC form data before sending to the Apex server side code.
We tried to use CryptoJS library in LWC component.Looks like we ...
0
votes
1
answer
802
views
Why am I getting "Input length must be multiple of 16 when decrypting with padded" error?
I'm writing an apex class to receive incoming AES256 encrypted data. I have a private key safely stored, and the incoming data includes an iv.
My logs show me that the retrieved private key is 32 ...
0
votes
1
answer
176
views
AMPScript AES Encrypted and Decrypt with Crypto Apex Class
I'm trying to decrypt the example that AMPScript has in the documentation https://ampscript.guide/encryptsymmetric/ using Crypto class.
I have desperately tried all the scenarios but I don't know if ...
0
votes
0
answers
87
views
OAuth1 sign a request with Crypto.generateHash
I'm trying to connect to a distant API (Netsuite).
I can send a request and get a successful response when connecting with Postman.
But when I try to do the same in Apex I get a 401 response. I ...
2
votes
1
answer
73
views
Generate Cybersource digest in Apex
Cybersource is asking to generate a digest from payload using byte array. However we don't have bytes in apex. I'm getting SHA-256=k3t9b6mL4zCMDTOi7N1uLQMu9XxrjwOr5yRXnTG0G1A= hash when I try to ...
1
vote
1
answer
153
views
Retrieve claims from a jwt with apex
I'm trying to retrieve the claims, audience, issuer, subject from a JWT in apex, according to this documentation:
https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/...
0
votes
0
answers
154
views
How to verify a JWT id token signature in an Apex Class
I try to verify a JWT signature in an apex class.
It is a RS SHA 256 token.
It is an id token received from Auth0.
Blob bPublicKey = EncodingUtil.base64Decode(publicKey);
Blob bsignature = ...
0
votes
1
answer
66
views
How to encrypt with unknown initialization vector?
How can I generate an AES encrypted token with a shared key and using the following AES cipher attributes in apex?
Rijndael cipher
Electronic Code Book mode (ECB) / Galois Counter Mode (GCM)
No built ...
0
votes
0
answers
117
views
Validate SHA1 signed Payload
I am trying to validate SHA1 signed data sent to Salesforce through webhook json message. I am getting the error System.SecurityException: Invalid Crypto Key
I have PEM format public key. According to ...
1
vote
0
answers
168
views
Problems signing with Crypto.signWithCertificate()
I am trying to connect with an external service, which in its documentation asks me to generate a CMS from an XML and a certificate and private key with openssl :
In salesforce use "Certificate ...
0
votes
0
answers
127
views
Acquire access token via oAuth from Azure Active Directory
I'm using Crypto.signWithCertificate with a certificate in the Certificate and Key Management area. The platform I'm accessing (AAD) requires thumbprint of the certificate as part of the client ...
0
votes
1
answer
98
views
Payload encryption
We have a large request payload and customer would like to encrypt it before sending.Since SF crypto class have a limitation of 1MB , customer has asked us if it is possible to only encrypt the values ...
0
votes
1
answer
200
views
File encryption using Crypto in apex
I am trying to encrypt and decrypt file using apex but getting below error while decryption of file. Goal is to encrypt the file in salesforce and send it to third party. Third party should be able to ...
1
vote
1
answer
300
views
Decrypt Symmetrically/Asymmetrically Encrypted Data in MS SQL (T-SQL) Server via Apex Crypto Class
Hope you're doing well. Recently, I have been working on a project and haven't been able to find a solution to this problem.
What I want to achieve is: To decrypt the data in Apex using the crypto ...
1
vote
1
answer
203
views
Uniqueness of generated with Crypto.generateAesKey(128)
I want to generate a unique text for integration purposes using the following code fragment.
Blob cryptoKey = Crypto.generateAesKey(128);
String key = EncodingUtil.convertToHex(cryptoKey);
I ...
0
votes
0
answers
70
views
handle encrypted response of size more than 1mb
I m working on a Integration scenario where i am receiving encrypted data of size 2 mb. I am decrypting it with below piece of code:-
public static List<Object> decryptData(string body){
...
0
votes
0
answers
223
views
last block incomplete in decryption
I am trying to understand the "Crypto" class provided by Salesforce due to compliance needs with different systems for integration.
I am trying to make a combination of these 2 methods ...
0
votes
0
answers
575
views
How do I import a JKS where I do not have the private key
The public cert is issued by the claims provider.
It is for custom apex JWT verification. I get an error when uploading:
"Error: No certificate was imported because the keystore file doesn't ...
0
votes
1
answer
135
views
Removing Initialization Vector from Cipher Text
public static string getencRequest(){
String PLAIN_Request = 'merchant_id=90578&order_id=456¤cy=INR&amount=1.00&redirect_url=https://ceptes-sf-webhook-developer-edition....
1
vote
1
answer
948
views
Verify Signature with PEM Public Key
In Apex, how do I implement the webhook verification from Ironclad described here?
Their example uses Node.js and basically boils down to this:
const isValid = crypto
.createVerify(signAlgorithm)
...
0
votes
1
answer
799
views
Verify ECDSA signature from Ethereum signed message hash
For my use case I need to verify a ECDSA signature from a signed Ethereum message.
From the front end, the message is first converted into a Sha3/keccac256 hash using web3.js with below method:
https:/...
1
vote
1
answer
557
views
Salesforce APEX Crypto hash vs Javascript Crypto hash
Trying to generate a hash of a HMAC Sring in Salesforce. The hash generated using APEX in Salesforce is not identical when compared to a hash generated by JS code on the same message. Am I doing ...
1
vote
1
answer
4k
views
String encrypted using Crypto js can not decrypted via Crypto apex
We are encrypting a string using Crypto js library.
And we want to decrypt that encrypted string using Crypto apex class. But unfortunately, that is not working.
JS Code
CryptoJS.AES.encrypt('123', '...
0
votes
1
answer
871
views
Encrypt File Using Crypto JS in Aura Component
We want to encrypt the input file on client side using javascript in our aura component.
We are trying to use CryptoJS(https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js).
We have ...
3
votes
0
answers
305
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 ...
0
votes
1
answer
475
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
1
answer
681
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
1
answer
87
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 ...
4
votes
1
answer
832
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
1
answer
528
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
0
answers
586
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
1
answer
757
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
3
answers
3k
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
0
answers
212
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
1
answer
967
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
1
answer
321
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. ...
2
votes
2
answers
5k
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
2
answers
2k
views
Crypto.verify(..) - format of a public RSA 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
1
answer
2k
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
1
answer
650
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 ...
5
votes
2
answers
3k
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
1
answer
1k
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....
4
votes
1
answer
2k
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
1
answer
2k
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
0
answers
3k
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
1
answer
130
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
0
answers
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
2
answers
2k
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
1
answer
696
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
2
answers
571
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 ...