web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

How to encrypt PAN Number in this format using JWE Algorithm?

(0) ShareShare
ReportReport
Posted on by 5
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));
    }
 
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,106

#2
YUN ZHU Profile Picture

YUN ZHU 1,752 Super User 2025 Season 2

#3
OussamaSabbouh Profile Picture

OussamaSabbouh 1,670

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans