A guide for converting v2 identifiers to data representations

JavaScript

function asciiToHex(str) {
	var hex = [];
	for (var i = 0; i < str.length; i++) {
		hex(Number(str.charCodeAt(i)).toString(16));
	}
	return hex;
}
var identifier = 'parrotbill';	
var payload = new Uint8Array(asciiToHex(identifier));	

Objective-C

NSString *identifier = [NSString stringWithUTF8String:@"parrotbill"];

NSData *payload = [identifier dataUsingEncoding:NSUTF8StringEncoding];

Python

The Chirp Connect Python SDK accepts string directly - so an identifier can be passed directly - but a similar conversion can be performed if needed.

identifier = 'parrotbill'
payload = [ord(ch) for ch in identifier]