Skip to main content

Questions tagged [crypto]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
63 views

Fetch principal values from External Credential without callout

Is there a way to access principal's authentication details from ExternalCredential in apex. I tried: ConnectApi.ExternalCredential ec = ConnectApi.NamedCredentials.getExternalCredential('GCP_Key'); ...
Nagendra Singh's user avatar
2 votes
1 answer
33 views

Encryption via managed package

In my current project we are trying to redirect a logged in user from a webpage to a salesforce community page with guest user access. We want the community page to recognize the user and so we are ...
Dane's user avatar
  • 167
1 vote
0 answers
143 views

Failed to create a Valid JWT token

I am currently working on sending a request to Snowflake using Key Pair Authentication. They have provided me with a private key and a public key, and for testing purposes, I have hardcoded them as ...
Salvation's user avatar
  • 1,199
0 votes
0 answers
197 views

Decryption of Data failing in API calls

We have an Apex method in our Org which is exposed for a GET API request. The data is encrypted with AES256 before sending. However from the receiver end (Same Org for testing purpose), decryption of ...
Brav's user avatar
  • 819
0 votes
1 answer
5k 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 ...
PatMcClellan__c's user avatar
0 votes
1 answer
521 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 ...
Jaume Bonet's user avatar
0 votes
0 answers
257 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 ...
Emmanuel BRUNO's user avatar
2 votes
1 answer
199 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 ...
Shohrat Muhamov's user avatar
1 vote
1 answer
504 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/...
2095377's user avatar
  • 58
0 votes
0 answers
453 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 = ...
2095377's user avatar
  • 58
0 votes
1 answer
202 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 ...
Diego's user avatar
  • 545
0 votes
0 answers
194 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 ...
Óli Þór Gunnarsson's user avatar
1 vote
0 answers
345 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 ...
Martin Aguilera's user avatar
0 votes
0 answers
191 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 ...
fartwhif's user avatar
  • 101
0 votes
1 answer
257 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 ...
MBM's user avatar
  • 129
0 votes
1 answer
360 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 ...
Muzammil Bajaria's user avatar
1 vote
1 answer
460 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 ...
Assadullah Shaikh's user avatar
1 vote
1 answer
363 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 ...
Shiran's user avatar
  • 121
0 votes
0 answers
1k 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 ...
K A's user avatar
  • 1
0 votes
1 answer
186 views

Removing Initialization Vector from Cipher Text

public static string getencRequest(){ String PLAIN_Request = 'merchant_id=90578&order_id=456&currency=INR&amount=1.00&redirect_url=https://ceptes-sf-webhook-developer-edition....
Ifthikar Ahmed's user avatar
1 vote
1 answer
1k 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) ...
Diego's user avatar
  • 545
0 votes
1 answer
1k 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:/...
0xFlem's user avatar
  • 11
1 vote
1 answer
735 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 ...
Vamsi's user avatar
  • 11
1 vote
1 answer
5k 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', '...
Anil Meghnathi's user avatar
0 votes
1 answer
1k 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 ...
Anil Meghnathi's user avatar
3 votes
0 answers
480 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 ...
David Kohelet's user avatar
0 votes
1 answer
633 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?
Jagadeesh's user avatar
1 vote
1 answer
977 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 ...
bhavya's user avatar
  • 11
0 votes
1 answer
114 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 ...
Krishnamurthy's user avatar
4 votes
1 answer
1k 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 = ...
Eric's user avatar
  • 54.3k
1 vote
1 answer
595 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 //...
ipradhansk's user avatar
  • 2,337
2 votes
0 answers
807 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. ...
ds9972's user avatar
  • 189
0 votes
1 answer
908 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 ...
Neal Matta's user avatar
1 vote
3 answers
4k 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 ...
Shobhit Saxena's user avatar
1 vote
0 answers
250 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 ?
HSG's user avatar
  • 1,007
0 votes
1 answer
1k 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. ...
SK2889's user avatar
  • 929
1 vote
1 answer
364 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. ...
NITHESH K's user avatar
  • 2,545
3 votes
2 answers
6k 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'
AMDB6's user avatar
  • 86
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 ...
vanessen's user avatar
  • 2,705
3 votes
2 answers
3k 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 ...
Salvation's user avatar
  • 1,199
1 vote
1 answer
847 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 ...
Bahu SF's user avatar
  • 11
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 ...
Simon Goodyear's user avatar
0 votes
1 answer
2k 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....
GroundToCloud's user avatar
4 votes
1 answer
3k 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 ...
SatyaV's user avatar
  • 1,533
2 votes
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: ...
SatyaV's user avatar
  • 1,533
5 votes
0 answers
4k 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);...
Austin Evans's user avatar
1 vote
1 answer
148 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 ...
Learner111's user avatar
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 ...
david raj's user avatar
  • 622
2 votes
2 answers
3k 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 ...
Ross Bassett's user avatar
1 vote
2 answers
942 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 ...
Shane Kenyon's user avatar
  • 1,095