本文整理汇总了Java中com.facebook.crypto.Crypto类的典型用法代码示例。如果您正苦于以下问题:Java Crypto类的具体用法?Java Crypto怎么用?Java Crypto使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Crypto类属于com.facebook.crypto包,在下文中一共展示了Crypto类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BaseConcealPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public BaseConcealPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final T defaultValue) {
this.defaultValue = defaultValue;
this.stringPreference =
new ConcealStringPreference(crypto, preferences, key, String.valueOf(defaultValue));
}
示例2: ConcealIntPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealIntPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final int defaultValue) {
super(crypto, preferences, key, defaultValue);
}
示例3: ConcealFloatPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealFloatPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final float defaultValue) {
super(crypto, preferences, key, defaultValue);
}
示例4: ConcealStringSetPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealStringSetPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final Set<String> defaultValue) {
super(preferences, key, defaultValue);
this.crypto = crypto;
this.entity = Entity.create(key);
}
示例5: ConcealBooleanPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealBooleanPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final boolean defaultValue) {
super(crypto, preferences, key, defaultValue);
}
示例6: ConcealLongPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealLongPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final long defaultValue) {
super(crypto, preferences, key, defaultValue);
}
示例7: ConcealStringPreference
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public ConcealStringPreference(
final Crypto crypto,
final SharedPreferences preferences,
final String key,
final String defaultValue) {
super(preferences, key, defaultValue);
this.crypto = crypto;
this.entity = Entity.create(key);
}
示例8: setUp
import com.facebook.crypto.Crypto; //导入依赖的package包/类
@Before public void setUp() throws Exception {
SoLoader.init(InstrumentationRegistry.getContext(), false);
final SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getContext());
final Crypto crypto = AndroidConceal
.get()
.createDefaultCrypto(new SharedPrefsBackedKeyChain(
InstrumentationRegistry.getContext(),
CryptoConfig.KEY_256
));
factory = new ConcealPreferenceFactory(crypto, prefs);
}
示例9: setUp
import com.facebook.crypto.Crypto; //导入依赖的package包/类
@Before public void setUp() throws Exception {
final SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(InstrumentationRegistry.getContext());
final Crypto crypto = AndroidConceal
.get()
.createDefaultCrypto(new SharedPrefsBackedKeyChain(
InstrumentationRegistry.getContext(),
CryptoConfig.KEY_256
));
factory = new ConcealPreferenceFactory(crypto, prefs);
}
示例10: ICSNativeStringEncryption
import com.facebook.crypto.Crypto; //导入依赖的package包/类
ICSNativeStringEncryption(String password) {
this.password = password;
this.hashing = new Hashing();
this.encoding = new Encoding();
SystemNativeCryptoLibrary nativeCryptoLibrary = new SystemNativeCryptoLibrary();
MemoryKeyChain keyChain = new MemoryKeyChain(CryptoConfig.KEY_256, password, nativeCryptoLibrary);
this.crypto = new Crypto(keyChain, nativeCryptoLibrary, CryptoConfig.KEY_256);
}
示例11: DiskCache
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public DiskCache(Context context, String category) {
mCrypto = new Crypto(
new SharedPrefsBackedKeyChain(context),
new SystemNativeCryptoLibrary());
mCacheDir = new File(category);
if (mCacheDir.exists()) {
isLazyInit = true;
mCache = new DiskBasedCache(mCacheDir, DEFAULT_DISK_USAGE_BYTES);
initialize();
}
}
示例12: CryptoManager
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public CryptoManager(Context context, String path, String password) {
this.path = path;
this.crypto = new Crypto(
new SharedPrefsBackedKeyChain(context),
new SystemNativeCryptoLibrary());
entity = new Entity(password);
checkPathExists();
}
示例13: encryptingContent
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public static void encryptingContent(Context context, File file, byte[] plainTextBytes) throws Exception {
// Creates a new Crypto object with default implementations of
// a key chain as well as native library.
Crypto crypto = new Crypto(
new SharedPrefsBackedKeyChain(context),
new SystemNativeCryptoLibrary());
// Check for whether the crypto functionality is available
// This might fail if android does not load libaries correctly.
if (!crypto.isAvailable()) {
return;
}
OutputStream fileStream = new BufferedOutputStream(
new FileOutputStream(file));
// Creates an output stream which encrypts the data as
// it is written to it and writes it out to the file.
OutputStream outputStream = crypto.getCipherOutputStream(
fileStream,
new Entity("TEST1"));
// Write plaintext to it.
outputStream.write(plainTextBytes);
outputStream.close();
}
示例14: decryptingContent
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public static void decryptingContent(Context context, File file, String newPath) throws Exception {
// Get the file to which ciphertext has been written.
FileInputStream fileStream = new FileInputStream(file);
Crypto crypto = new Crypto(
new SharedPrefsBackedKeyChain(context),
new SystemNativeCryptoLibrary());
// Creates an input stream which decrypts the data as
// it is read from it.
InputStream inputStream = crypto.getCipherInputStream(
fileStream,
new Entity("TEST1"));
// Read into a byte array.
int read;
byte[] buffer = new byte[1024];
// You must read the entire stream to completion.
// The verification is done at the end of the stream.
// Thus not reading till the end of the stream will cause
// a security bug.
FileOutputStream fs = new FileOutputStream(newPath);
while ((read = inputStream.read(buffer)) != -1) {
fs.write(buffer, 0, read);
}
inputStream.close();
}
示例15: getCrypto
import com.facebook.crypto.Crypto; //导入依赖的package包/类
public Crypto getCrypto(){
return crypto;
}