Convert nonce Data to 6 character String

I am implementing Apple Wallet, where I need to add the card to the wallet. My payment gateway requires me to send a 6 digit alphanumeric nonce to them. However, if I try to convert the nonce which is of type Data, that I receive in the generateRequestWithCertificateChain PassKit delegate method, to HexEncoding String, I am getting 8 character String.

How to convert this nonce to a 6 digit hexString?

Code Block
func addPaymentPassViewController(_ controller: PKAddPaymentPassViewController, generateRequestWithCertificateChain certificates: [Data], nonce: Data, nonceSignature: Data, completionHandler handler: @escaping (PKAddPaymentPassRequest) -> Void)


I am converting nonce data to hexString using the following method
Code Block
func hexEncodedString(options: HexEncodingOptions = []) -> String {
let hexDigits = Array((options.contains(.upperCase) ? "0123456789ABCDEF" : "0123456789abcdef").utf16)
var chars: [unichar] = []
chars.reserveCapacity(2 * count)
for byte in self {
chars.append(hexDigits[Int(byte / 16)])
chars.append(hexDigits[Int(byte % 16)])
}
return String(utf16CodeUnits: chars, count: chars.count)
}

Did you manage to figure this out?
Convert nonce Data to 6 character String
 
 
Q