+ Start a Discussion
Rajasekhar TRajasekhar T 

encrypted password to plain text password Using 3DES algorithm?

I have encrypted password how to decrypt using 3des algorithm? is possible encrypting/decrypting anything in Apex Code?

Any help would be greatly appreciated

Raj
David HalesDavid Hales
Hi Raj,

Yes, Encryption and Decryption is possible in Salesforce Using Apex Class as well. Here, I am sharing an example with you where you can encrypt your Text Character in a secure code using different algorithms Which are available in Apex Class as well.

Available algorithm Name:
1. AES128
2. AES192
3. AES256
4. hmacMD5
5. hmacSHA1
6. hmacSHA256
7. hmacSHA512




Blob exampleIv = Blob.valueOf('Example of IV123');           // Please add Text here which you want to encrypt.
Blob key = Crypto.generateAesKey(128);                            // Here genrating ASCI code character to secure orginal Text 
 Blob data = Blob.valueOf('Data to be encrypted');              // Blob is also a data type.
Blob encrypted = Crypto.encrypt('AES128', key, exampleIv, data);                // Here, you can see the Algorithm Name "AES128"  
Blob decrypted = Crypto.decrypt('AES128', key, exampleIv, encrypted);
String decryptedString = decrypted.toString();
System.assertEquals('Data to be encrypted', decryptedString);        // Here, Receiver will get the original delivered Text value



For going in detail with encryption and decryption, please go through this URL as well AND Read about "Crypto Class" 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_crypto.htm 



Please mark the best Answer. if it resolves your problem. 
:)



Thank you
KSPL
1035
 
Rajasekhar TRajasekhar T
Thanks KSPL, can you please share me 3DES Algorithm example like AES128 Algorithm . my requirement is how to decrypt to encrypted password using 3DES Algorithm?
David HalesDavid Hales
Hi Raj,

As you mentioned that you required "3DES Algorithm" to encrypt you Private Text or To decrypt. 3DES Algorithm is not available in Salesforce Apex class but there are other algorithms available to do the encryption and decryption.  3DES Algorithm also Decode in 64Bit unique character so you can also do same encryption or decryption using given algorithm

String algorithmName = 'RSA';
String key = '';
Blob privateKey = EncodingUtil.base64Decode(key);
Blob input = Blob.valueOf('12345qwerty');
Crypto.sign(algorithmName, input, privateKey);



Thank You 
KSPL - 1035 (BODDH)

 
SAURABH RASTOGI 13SAURABH RASTOGI 13
Thanks KSPL, I really appreciate your effort It help me to solve a root cause of my development.  
Rajasekhar TRajasekhar T
Thanks KSPL, But what we need to pass algorithmName and Key parameters values for 3DES Algorithm in above encryption or decryption code ?