• AKK
  • NEWBIE
  • 5 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Hi, Can somebody help in creating HMACSHA256 api signature in apex using crypto class. Corresponding java code is given below :-

 

 public static void main(String[] args) throws GeneralSecurityException, IOException {
 
        String secretKey = "secretKey";
        String salt = "0123456789";
 
        String generateHmacSHA256Signature = generateHmacSHA256Signature(salt, secretKey);
        System.out.println("Signature: " + generateHmacSHA256Signature);
 
        String urlEncodedSign = URLEncoder.encode(generateHmacSHA256Signature, "UTF-8");
 
        System.out.println("Url encoded value: " + urlEncodedSign);
    }
 
    public static String generateHmacSHA256Signature(String data, String key) throws GeneralSecurityException {
        byte[] hmacData = null;
 
        try {
            SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
            Mac mac = Mac.getInstance("HmacSHA256");
            mac.init(secretKey);
            hmacData = mac.doFinal(data.getBytes("UTF-8"));
            return new Base64Encoder().encode(hmacData);
        } catch (UnsupportedEncodingException e) {
            throw new GeneralSecurityException(e);
        }
    }

 

Thanks in advance.

  • December 28, 2012
  • Like
  • 0

Hi, Can somebody help in creating HMACSHA256 api signature in apex using crypto class. Corresponding java code is given below :-

 

 public static void main(String[] args) throws GeneralSecurityException, IOException {
 
        String secretKey = "secretKey";
        String salt = "0123456789";
 
        String generateHmacSHA256Signature = generateHmacSHA256Signature(salt, secretKey);
        System.out.println("Signature: " + generateHmacSHA256Signature);
 
        String urlEncodedSign = URLEncoder.encode(generateHmacSHA256Signature, "UTF-8");
 
        System.out.println("Url encoded value: " + urlEncodedSign);
    }
 
    public static String generateHmacSHA256Signature(String data, String key) throws GeneralSecurityException {
        byte[] hmacData = null;
 
        try {
            SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
            Mac mac = Mac.getInstance("HmacSHA256");
            mac.init(secretKey);
            hmacData = mac.doFinal(data.getBytes("UTF-8"));
            return new Base64Encoder().encode(hmacData);
        } catch (UnsupportedEncodingException e) {
            throw new GeneralSecurityException(e);
        }
    }

 

Thanks in advance.

  • December 28, 2012
  • Like
  • 0

can u  please tell the return type parameter of ---Apexpages.currentPage().getParameters().get('one')

i am suppopse to get integer ,i have assigned to a list of integer.

but it is throwing and exception when i try to add to a list

Shine

 

 

Hi all,

 

You are gonna like this one!

 

I am getting an error on Eclipse 3.4.2 that restricts me to save, synchronize and/or deploy my project. It reads:

 

"Unable to fetch and save Force.com components to project:

 The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. (ALREADY_IN_PROCESS)"

 

Has anyone seen this error before? I have wait for 15 minutes (my max waiting capacity :( ), tried to refresh, deploy, save... but this error is not letting me go anywhere.

 

Suggestions are welcome

 

Alex

  • February 16, 2010
  • Like
  • 0
How can i Change Layout of Home Page of my custom application?
OR
 
Is there any way to redirect user after login in Salesforce account to own created page?