ph_base64decode PowerHome formula function
Description
Converts a base64 string back to its normal representation.
Syntax
ph_base64decode ( as_input )
ph_base64decode ( as_input, ai_type )
ph_base64decode ( as_input, as_output, ai_type )
Argument | Description |
as_input | String. The base64 string to decode |
as_output | String (Optional). A full path and filename to
write the decoded output to (only used if ai_type = 3) |
ai_type | Integer (Optional). Determines how the decoded
bytes are returned. Valid values are 0, 1, 2, and 3. If parameter is not included, a value of
0 is assumed. See Usage below |
Return value
String. Returns the decoded base64 input as determined by the ai_type parameter. If ai_type = 3, then the return value will be "*SUCCESS*".
Usage
Use this function to decode base64 encoded
data. When used to decode authorization via a webpage, the format is the userid,
a colon, and then
the password.
The allowed values for the ai_type parameter are:
0 - Return the decoded bytes as ASCII encoding
1 - Return the decoded bytes as UTF8 encoding
2 - Return the decoded bytes as a hex encoded string
3 - Write the decoded bytes to the path/filename contained in as_output. Returns "*SUCCESS*"
Any other value will return an empty string ""
Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_base64decode("dXNlcm5hbWU6cGFzc3dvcmQ=") -
Returns the decoded text
"username:password"
• ph_base64decode("dXNlcm5hbWU6cGFzc3dvcmQ=",2) -
Returns the decoded text as the hex encoded string:
"757365726E616D653A70617373776F7264"