function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Manoj DegaManoj Dega 

Indeed Email Encryption and decryption in apex

Hi Team, I need to encrypt email address in the apex.

Here is sample Java code. Pls, help me how to generate this?
 
String email = "jobs@example.com";
String api_secret = "your api secret key".getBytes(new Charset("UTF-8"));
byte[] keydata = new byte[16];
// get the first 16 bytes of the api secret
System.arraycopy(api_secret, 0, keydata, 0, keydata.length);
byte[] email_bytes = email.getBytes(Charsets.UTF_8);
// Create a SecretKeySpec using the shared api secret
SecretKeySpec key = SecretKeySpec(keydata, "AES");
// Encrypt the email
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
IvParameterSpec ivspec = new IvParameterSpec(new byte[]{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
cipher.init(Cipher.ENCRYPT_MODE, key, ivspec);
byte[] email_encrypted = cipher.doFinal(email_bytes);
// convert encrypted email to hex
StringBuilder buf = new StringBuilder(email_encrypted.length * 2);
for (byte b : email_encrypted) {
    String hexDigits = Integer.toHexString((int) b & 0x00ff);
    if (hexDigits.length() == 1)
        buf.append('0');
    buf.append(hexDigits);
}
String encrypted_email = buf.toString();

When using Indeed Apply through email, you must encrypt the email to which Indeed sends the applications. Indeed expects the email to be encrypted using the AES algorithm with your 128-bit secret key. The cipher mode is CBC with PKCS5 padding. The initialization vector is 16 bytes of 00.
Using your secret key, generate a 128-bit secret key using the first 16 bytes.
Read the bytes of the plain-text email encoded in "UTF-8".
Encrypt the email using the AES algorithm and your 128-bit key. Be sure to use CBC mode and PKCS5 padding.
Convert the encrypted bytes to hex string.
Use this hex string as your data-indeed-apply-email attribute.

Thanks in advance 
vijay jillella 9vijay jillella 9
dear Manoj,

please send the enitire indeed integration code.

Will be raelly thankful,want to post job in Indeed
jvijaykrupakar@gmail.com