Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base32


            String secret,
            long code,
            long tm,
            int window) {
        // Decoding the secret key to get its raw byte representation.
        Base32 codec = new Base32();
        byte[] decodedKey = codec.decode(secret);

        // convert unix time into a 30 second "window" as specified by the
        // TOTP specification. Using Google's default interval of 30 seconds.
        final long timeWindow = tm / KEY_VALIDATION_INTERVAL_MS;
View Full Code Here


     *
     * @param secretKey a random byte buffer.
     * @return the secret key.
     */
    private String calculateSecretKey(byte[] secretKey) {
        Base32 codec = new Base32();
        byte[] encodedKey = codec.encode(secretKey);

        // Creating a string with the Base32 encoded bytes.
        return new String(encodedKey);
    }
View Full Code Here

      dsa.update(stringData.getBytes("UTF-8"));
     
      final byte[] signed = dsa.sign();
     
      /* base 32 encode the signature */
      String result = new Base32().encodeAsString(signed);
     
      /* replace O with 8 and I with 9 */
      result = result.replace("O", "8").replace("I""9");
     
      /* remove padding if any. */
 
View Full Code Here

    /* Pad the output length to a multiple of 8 with '=' characters */
    while (licenseSignature.length() % 8 != 0) {
      licenseSignature += "=";
    }
   
    byte[] decoded = new Base32().decode(licenseSignature);
    try {
      Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
      dsa.initVerify(publicKey);
      dsa.update(stringData.getBytes("UTF-8"));
      return dsa.verify(decoded);
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Base32

Copyright © 2018 www.massapicom. 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.