Q:

base64 decode - nul in string

I'm trying to create function that will run private API calls on some sites.
All those sites are using authentication by signature of the API call as follows in php:
base64_encode( hash_hmac('sha512', $post_data, base64_decode($secret), true) )

Using package digest and RCurl I can easily write as:
base64Encode( hmac(key = base64Decode(secret), object = post_data, algo = 'sha512', raw = TRUE) )

I'm fighting whole day with the hmac key parameter input:
key = base64Decode(secret)

The issue is that hmac function accept only string value but base64Decode might return something more than just string:
str(base64Decode(secret))
chr "îă?ľÂÜĄ\vŽĺ\022""| __truncated__

This __truncated__ is the key issue here. So the next thing I've tried was take a raw output from decode function and rawToChar on it:
str(base64Decode(secret,mode='raw'))
raw [1:64] ee e3 3f be ...

rawToChar(base64Decode(secret,mode='raw'))

Error in rawToChar(base64Decode(secret,mode='raw')) : embedded nul in
  string:
  'îă?ľÂÜĄ\vŽĺ\022\0!^\026Č‹¶©wŚˇ0Î\035ë\026\r\001ňKÍ„Rř\003j„7¤Ň\nťä_\004m@ß\0Ă"c\0271˝ZnĚ55’v'

As we can see now, there is a mystery nul thing somewhere in my (not even yet) string. I don't care much about the nuls, I just need to pass this piece of data as input for hmac.

Is there any possibility to handle string with nul, just for pushing it farther as input upper function?
Is there any possibility to have hmac function key parameter accept raw object like this?

I tried also base64enc package with no success. I tried many many different conversions but everything is going back this simple 'nul in string'.
These sites are rather new and this authentication process looks like a standard API auth among them. There should be some way to handle that process in R.
If anyone want to test, 
secret <- '7uM/vsLcpQuOmOUSACFeFsiLtql3jKEwzh3rFg0B8kvNhFL4A2qEN6TSCp3kXwRtQN8AwyJjFzG9Wm7MNTWSdg=='

A:

Answer for the question 2. is:
hmac function already accept raw object instead of string.
This is the solution:
hmac(key = base64Decode(secret, mode='raw'),
 object = post_data,
 algo = 'sha512',
 raw = TRUE)

