Package com.restfb.util
Class EncodingUtils
- java.lang.Object
-
- com.restfb.util.EncodingUtils
-
public final class EncodingUtils extends Object
A collection of data-encoding utility methods.- Since:
- 1.6.13
- Author:
- Josef Gierbl, Mikael Grev, Mark Allen
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
decodeBase64(String base64)
Decodes a base64-encoded string, padding out if necessary.static String
encodeAppSecretProof(String appSecret, String accessToken)
Generates an appsecret_proof for facebook.static byte[]
encodeHex(byte[] data)
Encodes a hexbyte[]
from givenbyte[]
.
-
-
-
Method Detail
-
decodeBase64
public static byte[] decodeBase64(String base64)
Decodes a base64-encoded string, padding out if necessary.- Parameters:
base64
- The base64-encoded string to decode.- Returns:
- A decoded version of
base64
. - Throws:
NullPointerException
- Ifbase64
isnull
.
-
encodeHex
public static byte[] encodeHex(byte[] data)
Encodes a hexbyte[]
from givenbyte[]
.This function is equivalent to Apache commons-codec binary
new Hex().encode(byte[])
- Parameters:
data
- The data to encode as hex.- Returns:
- Hex-encoded
byte[]
- Throws:
NullPointerException
- Ifdata
isnull
.
-
encodeAppSecretProof
public static String encodeAppSecretProof(String appSecret, String accessToken)
Generates an appsecret_proof for facebook.See https://developers.facebook.com/docs/graph-api/securing-requests for more info
- Parameters:
appSecret
- The facebook application secretaccessToken
- The facebook access token- Returns:
- A Hex encoded SHA256 Hash as a String
-
-