Questions tagged [crypto]

The tag has no usage guidance.

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

Decrypt a fernet token in apex

hello, Fernet is used by another team to encrypta data with AES 128 in CBC mode. I have the fernet key (32 bytes) and the encryption key (16 bytes). This is the Fernet documentation: https://github....
user avatar
  • 617
0 votes
1 answer
27 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....
user avatar
1 vote
1 answer
103 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) ...
user avatar
  • 255
0 votes
1 answer
149 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:/...
user avatar
  • 1
0 votes
1 answer
87 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 ...
user avatar
  • 1
1 vote
1 answer
479 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', '...
user avatar
0 votes
1 answer
153 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 ...
user avatar
2 votes
0 answers
166 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 ...
user avatar
-1 votes
1 answer
210 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?
user avatar
1 vote
1 answer
264 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 ...
user avatar
  • 11
0 votes
1 answer
48 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 ...
user avatar
4 votes
1 answer
483 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 = ...
user avatar
  • 53.1k
1 vote
1 answer
270 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 //...
user avatar
  • 2,233
2 votes
0 answers
339 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. ...
user avatar
0 votes
1 answer
475 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 ...
user avatar
1 vote
3 answers
2k 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 ...
user avatar
1 vote
0 answers
115 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 ?
user avatar
  • 997
0 votes
1 answer
474 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. ...
user avatar
1 vote
1 answer
195 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. ...
user avatar
  • 2,444
2 votes
2 answers
2k 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'
user avatar
  • 76
1 vote
1 answer
1k 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 ...
user avatar
  • 2,393
3 votes
1 answer
1k 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 ...
user avatar
  • 959
1 vote
1 answer
408 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 ...
user avatar
  • 11
3 votes
2 answers
2k 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 ...
user avatar
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....
user avatar
3 votes
1 answer
1k 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 ...
user avatar
  • 1,490
1 vote
1 answer
881 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: ...
user avatar
  • 1,490
5 votes
0 answers
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);...
user avatar
1 vote
1 answer
73 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 ...
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 ...
user avatar
  • 603
2 votes
2 answers
1k 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 ...
user avatar
1 vote
1 answer
469 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 ...
user avatar
  • 930
1 vote
2 answers
365 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 ...
user avatar
  • 2,708
-1 votes
2 answers
402 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 ...
user avatar
2 votes
1 answer
1k views

Does 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("...
user avatar
2 votes
0 answers
138 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 ...
user avatar
  • 85
0 votes
1 answer
751 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....
user avatar
0 votes
1 answer
164 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 ...
user avatar
  • 529
1 vote
2 answers
2k 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 ...
user avatar
0 votes
1 answer
237 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: ...
user avatar
7 votes
2 answers
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()-...
user avatar
2 votes
0 answers
221 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 ...
user avatar
1 vote
2 answers
1k 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 ...
user avatar
2 votes
0 answers
453 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 ...
user avatar
  • 442
9 votes
1 answer
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. ...
user avatar
  • 7,543
1 vote
2 answers
329 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>" ...
user avatar
1 vote
1 answer
346 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(...
user avatar
0 votes
0 answers
877 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 ...
user avatar
-2 votes
1 answer
419 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[]...
user avatar
2 votes
0 answers
344 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 ...
user avatar