本文整理汇总了Java中info.guardianproject.cacheword.PassphraseSecrets类的典型用法代码示例。如果您正苦于以下问题:Java PassphraseSecrets类的具体用法?Java PassphraseSecrets怎么用?Java PassphraseSecrets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PassphraseSecrets类属于info.guardianproject.cacheword包,在下文中一共展示了PassphraseSecrets类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeWithPassphrase
import info.guardianproject.cacheword.PassphraseSecrets; //导入依赖的package包/类
private void initializeWithPassphrase() {
try {
String passphrase = mNewPassphrase.getText().toString();
if (!passphrase.isEmpty()) {
PassphraseSecrets p = (PassphraseSecrets)mCacheWord.getCachedSecrets();
mCacheWord.changePassphrase(p,passphrase.toCharArray());
//now remove the temp passphrase if it exists
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
if (settings.contains(ImApp.PREFERENCE_KEY_TEMP_PASS))
settings.edit().remove(ImApp.PREFERENCE_KEY_TEMP_PASS).commit();
finish();
}
} catch (Exception e) {
// TODO initialization failed
Log.e(TAG, "Cacheword pass initialization failed: " + e.getMessage());
}
}
示例2: resetPassphrase
import info.guardianproject.cacheword.PassphraseSecrets; //导入依赖的package包/类
void resetPassphrase () {
//set temporary passphrase
try {
PassphraseSecrets p = (PassphraseSecrets)mCacheWord.getCachedSecrets();
if (p != null) {
String tempPassphrase = UUID.randomUUID().toString();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
settings.edit().putString(ImApp.PREFERENCE_KEY_TEMP_PASS, tempPassphrase).apply();
mCacheWord.changePassphrase(p, tempPassphrase.toCharArray());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: changeDatabasePassphrase
import info.guardianproject.cacheword.PassphraseSecrets; //导入依赖的package包/类
/**
* Changes the database passphrase
*
* @param newPassphrase - The new passphrase
*
* @return A boolean indicating whether or not the database passphrase was
* changed successfully
*/
public static boolean changeDatabasePassphrase(String newPassphrase)
{
Log.i(TAG, "DatabaseContentProvider.changeDatabasePassphrase() called");
try
{
// Get the old encryption key
String oldEncryptionKey = DatabaseHelper.encodeRawKeyToStr(sCacheWordHandler.getEncryptionKey());
// Set CacheWord to use the new passphrase
sCacheWordHandler.changePassphrase((PassphraseSecrets) sCacheWordHandler.getCachedSecrets(), newPassphrase.toCharArray());
// Get the new encryption key
String newEncryptionKey = DatabaseHelper.encodeRawKeyToStr(sCacheWordHandler.getEncryptionKey());
sDatabase.execSQL("PRAGMA key = \"" + oldEncryptionKey + "\";");
sDatabase.execSQL("PRAGMA rekey = \"" + newEncryptionKey + "\";");
openDatabase();
return true;
}
catch (Exception e)
{
Log.e(TAG, "Exception occurred while running DatabaseContentProvider.changeDatabasePassphrase(). The exception message was:\n" +
e.getMessage());
return false;
}
}
示例4: setAuthToken
import info.guardianproject.cacheword.PassphraseSecrets; //导入依赖的package包/类
public byte[] setAuthToken(String authToken) {
SecretKey key = ((PassphraseSecrets) cacheWord.getCachedSecrets()).getSecretKey();
return AesUtility.EncryptToKey(key, authToken).getBytes(Wiper.Utf8CharSet);
}