I am saving password to database in my application. But now I want to save encrypted password to database. How can I achieve this ?

1 Answer 1


Use Apex Crypto Class, that will help. It has all required methods and exceptions etc. Refer this link -> Crypto Class

  • I want to use sha2 alogrithm for encryption. but in Crypto service there is no provision for sha2, Crypto class only uses AES algorithm. is there any hint ? Commented Jun 15, 2015 at 11:41
  • Crypto class has a method sign(algorithmName, input, privateKey) here algorithmName is of String that is used for name of the algorithm you want to use. Commented Jun 15, 2015 at 11:46
  • Follow the same link I have given in the answer. Commented Jun 15, 2015 at 11:47
  • Thanks Vivek, one more thing using sign() we can encrypt and generate hash using RSA SHA256. but how to decrypt encrypted message by sign() ? Commented Jun 15, 2015 at 12:07
  • Here is a simple example for encrypting and encrypting Commented Jun 15, 2015 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .