Questions tagged [crypto]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
86 views
+50

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
1answer
82 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
3answers
504 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
0answers
33 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
1answer
68 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
1answer
59 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. ...
0
votes
0answers
93 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
263 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
439 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
203 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
569 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
419 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
411 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 ...
0
votes
1answer
322 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: ...
4
votes
0answers
924 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
51 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
799 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
475 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
186 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
2answers
117 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
254 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 ...
2
votes
1answer
568 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("...
2
votes
0answers
65 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
1answer
452 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
1answer
34 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
782 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
147 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
1k 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
141 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
591 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
280 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
1k 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
219 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
205 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
398 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
277 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[]...
2
votes
0answers
267 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
73 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
220 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
151 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
3k 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
100 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
2k 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
44 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
250 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
458 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
121 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
138 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 ...