Questions tagged [crypto]

The tag has no usage guidance.

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

What is the equivalent of .net’s HMACSHA512.ComputeHash(counterBytes) in APEX

I’m trying to generate a Hash-based Message Authentication Code (HAMC) using apex. .net code for the same is given below: string key = "...
1
vote
1answer
64 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
100 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
96 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
226 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
101 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
106 views

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 ...
0
votes
1answer
127 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: ...
2
votes
0answers
133 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
36 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
447 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
1answer
195 views

JWT HS256 Signature Issues

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
93 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 ...
0
votes
1answer
59 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
150 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 ...
1
vote
1answer
277 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("...
1
vote
0answers
44 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
0answers
55 views

How to encrypt using ECB Mode in Apex? [duplicate]

My client asks me to use AES ECB PKCS5 128 encrypting method. I found a way to do it via JavaScript but that can presents some security issues. Unfortunately, ECB mode is not supported in Salesforce (...
0
votes
1answer
266 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
0answers
39 views

Using Crypto.signXml() to assign Digital Signature to Header Block

I have been trying to Cypto.signXml() to sign by XML document. I want to get the Digest and Signature of the Body element but have it inserted into a Security element within the soap Header. The XML ...
0
votes
1answer
26 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
427 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
90 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: ...
5
votes
2answers
599 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
111 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
327 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
203 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
785 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
143 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
160 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
180 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
186 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[]...
1
vote
0answers
215 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
59 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
160 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
111 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
2k 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
98 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 ...
0
votes
1answer
1k views

Encryption and Decryption in apex Salesforce Using Crypto Class

The below code works sometimes and sometimes it gives an error. The error is like this. Input length must be multiple of 16 when decrypting with the padded cipher. I am getting an error in decryption ...
1
vote
1answer
37 views

Encryption Key visibility for Admins in AppExchange Product

We are using a private key for encryption. At the time of installation, we are generating a random key using Salesforce Crypto class and storing that key in a custom setting. Admins will be able to ...
0
votes
1answer
156 views

How to obtain the original text from encrypted text in signWithCertificate() method

I have problem with working with digital signature. In controller encryptWithManagedIV() function is encrypted and decrypted properly. But i don't know how to work with signWithCertificate, how to ...
1
vote
1answer
367 views

Related to Digital signiature

Something related to Digital signature if we have a doc in sales-force and needs to be digitally signed, which involves digital certificates.. and how we can use crypto class of apex in this. also ...
1
vote
1answer
112 views

Two-Way SSL vs Crypto Class

I would study and understand the differences about these two technologies in Apex. I know that in Two-Way SSL both the client and the server uses a certificate to "check" the other while whith Crypto ...
1
vote
1answer
37 views

Comparing Message Authentication Codes in Apex

I'm trying to incorporate message authentication into an application I'm working on. Ideally, I need to verify that the MAC generated by the requester matches the recomputed MAC on the server side. ...
1
vote
1answer
1k views

JWT verify signature

I've got a jwt base64 encoded payload and a public certificate. I am able to decode the payload in apex but having hard time validating the signature. Its header has the algorithm RS256. How do I do ...
1
vote
0answers
132 views

How to check a signature using crypto class when you only have access to the “signature and public key” (i.e. not the private key)? [duplicate]

In the salesforce there is a function Crypto.sign() that computes a unique digital signature for the input string, using the specified algorithm and the supplied private key. What I want to do is the ...
2
votes
1answer
381 views

How do I convert a Blob into an alphanumeric string and back?

There's a Blob I generated by encrypting a certain string: Blob data = Blob.valueOf('my string'); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Is there a way to ...
3
votes
1answer
1k views

Private and Public Key in Salesforce From Apex

I am using the function Crypto.sign(algorithmName, input, privateKey) from the Crypto class as follows: String algorithmName = 'RSA'; String key = ''; Blob privateKey = EncodingUtil.base64Decode(key);...
2
votes
1answer
1k views

How to create RS256 signature using apex

I read the Question from here: How to create HMAC-SHA-256 signature using apex I need the same thing but I would like to use the RS256 algorithm. How can I do it?
7
votes
2answers
183 views

LockerService and window.crypto.getRandomValues()

When LockerService is enabled and I run the example code from Mozilla: var array = new Uint32Array(10); window.crypto.getRandomValues(array); I get this error: Uncaught TypeError: Failed to ...