Package javax.crypto

Examples of javax.crypto.Mac.doFinal()


                // also should not happen
                throw new RuntimeException("Could not initialize the MAC algorithm", e);
            }

            // Compute the HMAC on the digest, and set it.
            String b64=Base64.encodeBytes(mac.doFinal(canonicalString.getBytes()));

            if(urlencode) {
                return urlencode(b64);
            }
            else {
View Full Code Here


          SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
          Mac mac = Mac.getInstance("HmacSHA1");
          mac.init(signingKey);
   
          byte[] rawHmac = mac.doFinal(data);
   
          return encodeBase64(rawHmac);
         
      } catch (NoSuchAlgorithmException nsae) {
          throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

            String algorithm = _macKey.getAlgorithm();
            Mac mac = Mac.getInstance(algorithm);

            mac.init(_macKey);

            return mac.doFinal(data);
        }
        catch (GeneralSecurityException e)
        {
            throw new AssociationException("Cannot sign!", e);
        }
View Full Code Here

          SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
          Mac mac = Mac.getInstance("HmacSHA1");
          mac.init(signingKey);
   
          byte[] rawHmac = mac.doFinal(data);
   
          return encodeBase64(rawHmac);
         
      } catch (NoSuchAlgorithmException nsae) {
          throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

            SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(signingKey);
   
            byte[] rawHmac = mac.doFinal(data);
   
            return encodeBase64(rawHmac);
           
        } catch (NoSuchAlgorithmException nsae) {
            throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

          SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
          Mac mac = Mac.getInstance("HmacSHA1");
          mac.init(signingKey);
   
          byte[] rawHmac = mac.doFinal(data);
   
          return encodeBase64(rawHmac);
         
      } catch (NoSuchAlgorithmException nsae) {
          throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

            SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(signingKey);
   
            byte[] rawHmac = mac.doFinal(data);
   
            return encodeBase64(rawHmac);
           
        } catch (NoSuchAlgorithmException nsae) {
            throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

          SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");
   
          Mac mac = Mac.getInstance("HmacSHA1");
          mac.init(signingKey);
   
          byte[] rawHmac = mac.doFinal(data);
   
          return encodeBase64(rawHmac);
         
      } catch (NoSuchAlgorithmException nsae) {
          throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
View Full Code Here

        try {
            Mac mac = Mac.getInstance(algorithm);
            mac.init(key);
            mac.update(bytes);

            return mac.doFinal();
        } catch (NoSuchAlgorithmException e) {
            //shouldn't happen
        } catch (InvalidKeyException e) {
            //shouldn't happen
        }
View Full Code Here

        random.nextBytes(b);
        final SecretKey secretKey = new SecretKeySpec(b, HMAC_SHA1);
        final Mac m = Mac.getInstance(HMAC_SHA1);
        m.init(secretKey);
        m.update(UTF_8.getBytes(UTF_8));
        m.doFinal();
    }

    /**
     * @param expires
     * @param userId
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.