You have to convert the int to a char array by using sprintf. itoa is not supported by every compiler.
Unfortunately you have to cast types, as xxtea is dealing with unsigned char*, whereas the C functions are dealing with char*.
xxtea_long retLength = 0;
char data[sizeof(int)];
auto bytes = sprintf(data, "%d", num);
xxtea_long dataLength = sizeof(data);
unsigned char key[] = "key";
xxtea_long keyLength = sizeof(key);
unsigned char *encryptedData = xxtea_encrypt(reinterpret_cast<unsigned char*>(data), dataLength, key, keyLength, &retLength);
CCLOG("encrypted data: %s", encryptedData);
CCLOG("hashed data: %#8x", XXH32(dat, dataLength, seed));
// saving to UserDefault:
UserDefault::getInstance()->setStringForKey(forKey, std::string((char*)encryptedData));
In another function use this to receive data from UserDefault:
auto value = UserDefault::getInstance()->getStringForKey(forKey);
auto decryptedData = reinterpret_cast<unsigned char*>(const_cast<char*>(value.c_str()));
unsigned char *decryptedData = xxtea_decrypt(decryptedData, retLength, key, keyLength, &retLength);
CCLOG("decryped data: %s", decryptedData);
To UserDefaultEnc?
You still have to deal with casting issues, as it’s using std::string but xxtae is using POD types, not compatible with other C functions (unsigned char* vs. (const) char *). You have to do very nasty casting stuff.
The encrypteData and decrypteData functions of UserDefaultEnc are not encrypting data, they are just Base64 encoding and decoding functions!
UserDefaultEnc should maybe be called UserDefaultEncoding. The current implementation does not provide any encryption, so it might be a little confusing 
Maybe it’s also a good/better idea, to modify UserDefault itself. providing encoding/hashing/encryption instead of implementing a wrapper.