com.sponsorpay.sdk.android
Class SignatureTools
java.lang.Object
com.sponsorpay.sdk.android.SignatureTools
public class SignatureTools
- extends java.lang.Object
Contains convenience methods to generate digital signatures for texts and URL-encoded key-value maps.
Method Summary |
private static java.lang.String |
byteArray2Hex(byte[] hash)
|
static java.lang.String |
generateSignatureForParameters(java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.String secretToken)
Returns the SHA1 hash of a key-value map serialized into a string in URL-encoded form, ordered alphabetically by
key in the following form: |
static java.lang.String |
generateSignatureForString(java.lang.String text,
java.lang.String secretToken)
Appends the provided secret token to the provided clear text and returns the SHA1 hash of the result. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NO_SHA1_RESULT
public static final java.lang.String NO_SHA1_RESULT
- See Also:
- Constant Field Values
SHA1_ALGORITHM
private static final java.lang.String SHA1_ALGORITHM
- See Also:
- Constant Field Values
SignatureTools
public SignatureTools()
generateSignatureForParameters
public static java.lang.String generateSignatureForParameters(java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.String secretToken)
Returns the SHA1 hash of a key-value map serialized into a string in URL-encoded form, ordered alphabetically by
key in the following form:
key_1=value_1&key_2&value_2&...&key_n=value_n&secret_token
- Parameters:
parameters
- The key-value map to generate the signature from.secretToken
- The secret_token to append at the end of the URL-encoded string before hashing it.
- Returns:
- The SHA1 hash or
NO_SHA1_RESULT
if no SHA1 algorithm is available.
generateSignatureForString
public static java.lang.String generateSignatureForString(java.lang.String text,
java.lang.String secretToken)
- Appends the provided secret token to the provided clear text and returns the SHA1 hash of the result.
- Parameters:
text
- The clear text.secretToken
- The secret token.
- Returns:
- The SHA1 hash of text + secret token or
NO_SHA1_RESULT
if no SHA1 algorithm is available.
byteArray2Hex
private static java.lang.String byteArray2Hex(byte[] hash)