Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [crypto]

The tag has no usage guidance.

1
vote
1answer
17 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
50 views

Translate pseudo code to Salesforce Apex [on hold]

This is not a duplicate of [a link] (REST Request - AWS Access Key ID and AWS Secret Access Key) // This is related to the original question but is more specific in terms of //actual code snippet for ...
0
votes
0answers
28 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
59 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 ...
0
votes
1answer
37 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
37 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
53 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
112 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
27 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
24 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
60 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
19 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
19 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
1answer
164 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
55 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
278 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
81 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
246 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
129 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
453 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
87 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
99 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
116 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
126 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
183 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
48 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
107 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
79 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
1k 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
90 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
816 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
36 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
114 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
294 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
97 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
36 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
775 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
86 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
294 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
747 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);...
1
vote
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?
0
votes
1answer
366 views

How to import/use a Key file got from third party to do encryption before sending the encrypted value to the third party

For one of my current implementation to send out some params in a REST webservice, the external system with which we are integrating requires those params to be encrypted. I am using Crypto class in ...
7
votes
2answers
156 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 ...
2
votes
1answer
186 views

Use Integer List Key with Apex Crypto

SO if i am given a private key as follow: [242, 2, 56, 23, 15, 5, 12, 105, 19, 47, 116, 89, 25, 152, 200, 215] and an initialization vector: [194, 125, 123, 26, 93, 136, 191, 35, 20, 86, 167, 197, ...
6
votes
2answers
881 views

Integer Array to Base64 String

So I am struggling a bit to convert some code written in java to APEX. The struggle here is that I have an integer array as one of my encryption key, it looks something similar to this below: [242, 2,...
2
votes
1answer
86 views

Does Crypto class support SHA384?

We are calling a service from salesforce. This service is expecting a specific hash in the httpHeaders collection of the HTTP Request. The service is written in .NET and the hash is computed using ...
1
vote
1answer
199 views

how to send crypto data token id in the request header

i am making a request to a endpoint in apex. i have encrypted data and key using crypto class, now i want to send the encrypted data and token id in the request header for authorization using GET ...
3
votes
1answer
260 views

Certificates - api or sobject access

I use Crypto class to sign some data with certificate. The method signWithCertificate(algorithmName, input, certDevName) uses the certificate name. Now I am coding the admin page which will allow ...
9
votes
1answer
2k views

SHA1 Hash Results

I am trying to encryption a string using SHA1 encryption. Test string The quick brown fox jumps over the lazy dog 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 (encryption token) You can validate ...
0
votes
1answer
65 views

Crypto class with Chatter

We are using Salesforce as the front end (UI) for our CSR's; external system will be the system of record (backend). We are planning to build eMessaging system using the combination of Salesforce ...