Java 类com.facebook.crypto.Crypto 实例源码

项目:Patrons    文件:BaseConcealPreference.java   
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));
}
项目:Patrons    文件:ConcealIntPreference.java   
public ConcealIntPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key,
    final int defaultValue) {
  super(crypto, preferences, key, defaultValue);
}
项目:Patrons    文件:ConcealFloatPreference.java   
public ConcealFloatPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key,
    final float defaultValue) {
  super(crypto, preferences, key, defaultValue);
}
项目:Patrons    文件:ConcealStringSetPreference.java   
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);
}
项目:Patrons    文件:ConcealBooleanPreference.java   
public ConcealBooleanPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key,
    final boolean defaultValue) {
  super(crypto, preferences, key, defaultValue);
}
项目:Patrons    文件:ConcealLongPreference.java   
public ConcealLongPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key,
    final long defaultValue) {
  super(crypto, preferences, key, defaultValue);
}
项目:Patrons    文件:ConcealStringPreference.java   
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);
}
项目:Patrons    文件:ConcealIntPreferenceTest.java   
@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);
}
项目:Patrons    文件:ConcealIntPreferenceTest.java   
@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);
}
项目:encryptedprefs    文件:ICSNativeStringEncryption.java   
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);
}
项目:coder-tools-object-cacher    文件:DiskCache.java   
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();
    }
}
项目:DroidCon-Poland    文件:CryptoManager.java   
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();
}
项目:coder-tools-object-cacher    文件:DiskCache.java   
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();
    }
}
项目:UltimateAndroid    文件:CryptoUtils.java   
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();
    }
项目:UltimateAndroid    文件:CryptoUtils.java   
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();
    }
项目:UltimateAndroid    文件:CryptoUtils.java   
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();
    }
项目:UltimateAndroid    文件:CryptoUtils.java   
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();
    }
项目:ConcealSharedPreference-Android    文件:ConcealCrypto.java   
public Crypto getCrypto(){
    return crypto;
}
项目:Patrons    文件:ConcealIntPreference.java   
public ConcealIntPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, 0);
}
项目:Patrons    文件:ConcealFloatPreference.java   
public ConcealFloatPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, 0f);
}
项目:Patrons    文件:ConcealStringSetPreference.java   
public ConcealStringSetPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, null);
}
项目:Patrons    文件:ConcealBooleanPreference.java   
public ConcealBooleanPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, false);
}
项目:Patrons    文件:ConcealLongPreference.java   
public ConcealLongPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, 0L);
}
项目:Patrons    文件:ConcealStringPreference.java   
public ConcealStringPreference(
    final Crypto crypto,
    final SharedPreferences preferences,
    final String key) {
  this(crypto, preferences, key, null);
}
项目:Patrons    文件:ConcealPreferenceFactory.java   
public ConcealPreferenceFactory(
    final Crypto crypto,
    final SharedPreferences sharedPreferences) {
  this.crypto = crypto;
  this.sharedPreferences = sharedPreferences;
}
项目:Sunazuri    文件:EncryptionUtils.java   
public static String encrypt(Crypto crypto, String alias, String plainText)
        throws IOException, KeyChainException, CryptoInitializationException {
    final byte[] bytes = crypto.encrypt(plainText.getBytes(ENCODING), Entity.create(alias));
    return Base64.encodeToString(bytes, BASE64_FLAG);
}
项目:Sunazuri    文件:EncryptionUtils.java   
public static String decrypt(Crypto crypto, String alias, String encryptedText)
        throws IOException, KeyChainException, CryptoInitializationException {
    final byte[] bytes = crypto.decrypt(Base64.decode(encryptedText, BASE64_FLAG), Entity.create(alias));
    return new String(bytes, ENCODING);
}
项目:LsPush    文件:PreferenceUtils.java   
public PreferenceUtils(Gson gson, SharedPreferences preferences, Crypto crypto) {
    mGson = gson;
    mPreference = preferences;
    mCrypto = crypto;
}
项目:droid-stealth    文件:ConcealCrypto.java   
public ConcealCrypto(Context context) {
    crypto = new Crypto(
            new SharedPrefsBackedKeyChain(context),
            new SystemNativeCryptoLibrary());
}