Java 类com.facebook.crypto.util.SystemNativeCryptoLibrary 实例源码

项目: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();
    }
项目:droid-stealth    文件:ConcealCrypto.java   
public ConcealCrypto(Context context) {
    crypto = new Crypto(
            new SharedPrefsBackedKeyChain(context),
            new SystemNativeCryptoLibrary());
}