本文整理汇总了Java中com.keepassdroid.database.exception.InvalidKeyFileException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidKeyFileException类的具体用法?Java InvalidKeyFileException怎么用?Java InvalidKeyFileException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidKeyFileException类属于com.keepassdroid.database.exception包,在下文中一共展示了InvalidKeyFileException类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompositeKey
import com.keepassdroid.database.exception.InvalidKeyFileException; //导入依赖的package包/类
protected byte[] getCompositeKey(String key, InputStream keyfileStream)
throws InvalidKeyFileException, IOException {
assert(key != null && keyfileStream != null);
byte[] fileKey = getFileKey(keyfileStream);
byte[] passwordKey = getPasswordKey(key);
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new IOException("SHA-256 not supported");
}
md.update(passwordKey);
return md.digest(fileKey);
}
示例2: getMasterKey
import com.keepassdroid.database.exception.InvalidKeyFileException; //导入依赖的package包/类
public byte[] getMasterKey(String key, InputStream keyfileStream)
throws InvalidKeyFileException, IOException {
assert (key != null && keyfileStream != null);
if (key.length() > 0 && keyfileStream != null) {
return getCompositeKey(key, keyfileStream);
} else if (key.length() > 0) {
return getPasswordKey(key);
} else if (keyfileStream != null) {
return getFileKey(keyfileStream);
} else {
throw new IllegalArgumentException("Key cannot be empty.");
}
}
示例3: setMasterKey
import com.keepassdroid.database.exception.InvalidKeyFileException; //导入依赖的package包/类
public void setMasterKey(String key, InputStream keyfileStream)
throws InvalidKeyFileException, IOException {
assert( key != null && keyfileStream != null );
masterKey = getMasterKey(key, keyfileStream);
}