当前位置: 首页>>代码示例>>Java>>正文


Java DecodingException类代码示例

本文整理汇总了Java中com.google.android.apps.authenticator.Base32String.DecodingException的典型用法代码示例。如果您正苦于以下问题:Java DecodingException类的具体用法?Java DecodingException怎么用?Java DecodingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DecodingException类属于com.google.android.apps.authenticator.Base32String包,在下文中一共展示了DecodingException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateKeyAndUpdateStatus

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
private boolean validateKeyAndUpdateStatus(boolean submitting) {
  String userEnteredKey = getEnteredKey();
  try {
    byte[] decoded = Base32String.decode(userEnteredKey);
    if (decoded.length < MIN_KEY_BYTES) {
      // If the user is trying to submit a key that's too short, then
      // display a message saying it's too short.
      mKeyEntryField.setError(submitting ? getString(R.string.enter_key_too_short) : null);
      return false;
    } else {
      mKeyEntryField.setError(null);
      return true;
    }
  } catch (DecodingException e) {
    mKeyEntryField.setError(getString(R.string.enter_key_illegal_char));
    return false;
  }
}
 
开发者ID:google,项目名称:google-authenticator-android,代码行数:19,代码来源:EnterKeyActivity.java

示例2: testRegressionValuesFromRfc4648

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
public void testRegressionValuesFromRfc4648() throws DecodingException {
  // check encoding
  assertEquals(OUTPUT1, Base32String.encode(INPUT1));
  assertEquals(OUTPUT2, Base32String.encode(INPUT2));
  assertEquals(OUTPUT3, Base32String.encode(INPUT3));
  assertEquals(OUTPUT4, Base32String.encode(INPUT4));

  // check decoding
  MoreAsserts.assertEquals(INPUT1, Base32String.decode(OUTPUT1));
  MoreAsserts.assertEquals(INPUT2, Base32String.decode(OUTPUT2));
  MoreAsserts.assertEquals(INPUT3, Base32String.decode(OUTPUT3));
  MoreAsserts.assertEquals(INPUT4, Base32String.decode(OUTPUT4));
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:14,代码来源:Base32StringTest.java

示例3: checkDecoding

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
private byte[] checkDecoding(String s) {
  try {
    return Base32String.decode(s);
  } catch (DecodingException e) {
    return null; // decoding failed.
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:8,代码来源:Base32StringTest.java

示例4: getCheckCode

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
static String getCheckCode(String secret) throws GeneralSecurityException,
    DecodingException {
  final byte[] keyBytes = Base32String.decode(secret);
  Mac mac = Mac.getInstance("HMACSHA1");
  mac.init(new SecretKeySpec(keyBytes, ""));
  PasscodeGenerator pcg = new PasscodeGenerator(mac);
  return pcg.generateResponseCode(0L);
}
 
开发者ID:google,项目名称:google-authenticator-android,代码行数:9,代码来源:CheckCodeActivity.java

示例5: decodeKey

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
private static byte[] decodeKey(String secret) throws DecodingException {
  return Base32String.decode(secret);
}
 
开发者ID:google,项目名称:google-authenticator-android,代码行数:4,代码来源:AccountDb.java

示例6: testAmbiguousDecoding

import com.google.android.apps.authenticator.Base32String.DecodingException; //导入依赖的package包/类
/**
 * Base32String implementation is not the same as that of RFC 4648, it drops
 * the last incomplete chunk and thus accepts encoded strings that should have
 * been rejected; also this results in multiple encoded strings being decoded
 * to the same byte array.
 * This test will catch any changes made regarding this behavior.
 */
public void testAmbiguousDecoding() throws DecodingException {
  byte[] b16 = Base32String.decode("7777777777777777"); // 16 7s.
  byte[] b17 = Base32String.decode("77777777777777777"); // 17 7s.
  MoreAsserts.assertEquals(b16, b17);
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:13,代码来源:Base32StringTest.java


注:本文中的com.google.android.apps.authenticator.Base32String.DecodingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。