I have a pan number in below JSON format
{
/pannumber/:/GUYTE6687U/
}
I want to encrypt and decrypt the above pannumber using Algorithm: JWEAlgorithm.A256KW Encryption Method: A128CBC_HS25. I have the encryption/decryption code in JAVA. I want to know how to do the same in AL or using dot net.
Below is the JAVA code. I want the encryption with the following headings /encrypted_key/, /protected/, /ciphertext/, /iv/ and /tag/.
public static void encryptRequest(JSONObject jsonObject) throws JoseException {
Key key = new AesKey(DatatypeConverter.parseHexBinary(PRIVATE_KEY_STRING));
JsonWebEncryption jwe = new JsonWebEncryption();
jwe.setPayload(jsonObject.toJSONString());
jwe.setAlgorithmHeaderValue(/A256KW/);
jwe.setEncryptionMethodHeaderParameter(/A128CBC-HS256/);
jwe.setKey(key);
String serializedJwe = jwe.getCompactSerialization();
String[] components = CompactSerializer.deserialize(serializedJwe);
Map<String, Object> map = new HashMap<String, Object>();
map.put(/protected/, components[0]);
map.put(/ciphertext/, components[3]);
map.put(/iv/, components[2]);
map.put(/tag/, components[4]);
Map<String, String> encryptedKey = new HashMap<String, String>();
encryptedKey.put(/encrypted_key/, components[1]);
map.put(/recipients/, Arrays.asList(new Map[]{encryptedKey}));
System.out.println(/Encrypted Text: / + JSONObject.toJSONString(map));
}