• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CryptoInitializationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.facebook.crypto.exception.CryptoInitializationException的典型用法代码示例。如果您正苦于以下问题:Java CryptoInitializationException类的具体用法?Java CryptoInitializationException怎么用?Java CryptoInitializationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CryptoInitializationException类属于com.facebook.crypto.exception包,在下文中一共展示了CryptoInitializationException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: set

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
@Override public void set(final Set<String> value) {
  final Set<String> encryptedSet = new HashSet<>(value.size());
  for (final String s : value) {
    try {
      encryptedSet.add(Base64.encodeToString(
          crypto.encrypt(
              s.getBytes(Charset.defaultCharset()),
              entity
          ),
          Base64.NO_WRAP
      ));
    } catch (KeyChainException | CryptoInitializationException | IOException e) {
      Log.e(TAG, e.getMessage());
      encryptedSet.add(null);
    }
  }
  preferences.edit().putStringSet(key, encryptedSet).apply();
}
 
开发者ID:prolificinteractive,项目名称:Patrons,代码行数:19,代码来源:ConcealStringSetPreference.java


示例2: set

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
@Override public void set(final String value) {
  try {
    if (value != null) {
      super.set(Base64.encodeToString(
          crypto.encrypt(
              value.getBytes(Charset.defaultCharset()),
              entity
          ),
          Base64.NO_WRAP
      ));
    } else {
      delete();
    }
  } catch (KeyChainException | CryptoInitializationException | IOException e) {
    Log.e(TAG, e.getMessage());
  }
}
 
开发者ID:prolificinteractive,项目名称:Patrons,代码行数:18,代码来源:ConcealStringPreference.java


示例3: getCipherKey

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
@Override
public synchronized byte[] getCipherKey() throws KeyChainException {
    if (!setCipherKey) {
        PasswordBasedKeyDerivation derivation = new PasswordBasedKeyDerivation(secureRandom, nativeCryptoLibrary);
        derivation.setPassword(password);
        derivation.setSalt(password.getBytes());
        derivation.setIterations(ITERATION_COUNT);

        derivation.setKeyLengthInBytes(cryptoConfig.keyLength);

        try {
            cipherKey = derivation.generate();
        } catch (CryptoInitializationException e) {
            return null;
        }
    }
    setCipherKey = true;
    return cipherKey;
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:20,代码来源:MemoryKeyChain.java


示例4: encrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
private String encrypt(final String plainText) {
    if (TextUtils.isEmpty(plainText)) {
        return plainText;
    }

    byte[] cipherText = null;

    if (!crypto.isAvailable()) {
        log(Log.WARN, "encrypt: crypto not available");
        return null;
    }

    try {
        cipherText = crypto.encrypt(plainText.getBytes(), entity);
    } catch (KeyChainException | CryptoInitializationException | IOException e) {
        log(Log.ERROR, "encrypt: " + e);
    }

    return cipherText != null ? Base64.encodeToString(cipherText, Base64.DEFAULT) : null;
}
 
开发者ID:KaKaVip,项目名称:secure-preferences,代码行数:21,代码来源:SecurePreferences.java


示例5: decrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
private String decrypt(final String encryptedText) {
    if (TextUtils.isEmpty(encryptedText)) {
        return encryptedText;
    }

    byte[] plainText = null;

    if (!crypto.isAvailable()) {
        log(Log.WARN, "decrypt: crypto not available");
        return null;
    }

    try {
        plainText = crypto.decrypt(Base64.decode(encryptedText, Base64.DEFAULT), entity);
    } catch (KeyChainException | CryptoInitializationException | IOException e) {
        log(Log.ERROR, "decrypt: " + e);
    }

    return plainText != null
            ? new String(plainText)
            : null;
}
 
开发者ID:KaKaVip,项目名称:secure-preferences,代码行数:23,代码来源:SecurePreferences.java


示例6: obscureFile

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public File obscureFile(File file,boolean deleteOldFile){
    if (enableCrypto) {
        try {
            boolean isImage = FileUtils.isFileForImage(file);

            File mEncryptedFile = new File(makeDirectory()+DEFAULT_PREFIX_FILENAME+file.getName());
            OutputStream fileStream = new BufferedOutputStream(new FileOutputStream(mEncryptedFile));
            OutputStream outputStream = crypto.getCipherOutputStream(fileStream, mEntityPassword);

            int read;
            byte[] buffer = new byte[1024];
            BufferedInputStream  bis = new BufferedInputStream(new FileInputStream(file));
            while ((read = bis.read(buffer)) != -1) {
                outputStream.write(buffer, 0, read);
            }
            outputStream.close();
            bis.close();

            if (deleteOldFile)
                file.delete();

            File pathDir = new File(isImage?makeImagesDirectory():makeFileDirectory());
            return FileUtils.moveFile(mEncryptedFile,pathDir);

        } catch (KeyChainException | CryptoInitializationException | IOException e) {
            e.printStackTrace();
            return null;
        }
    }
    else {
        return file;
    }
}
 
开发者ID:afiqiqmal,项目名称:ConcealSharedPreference-Android,代码行数:35,代码来源:ConcealCrypto.java


示例7: put

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
private void put(String key, String hashKey, String value)
    throws KeyChainException, CryptoInitializationException, IOException {
    Entity entity = Entity.create(key); // original key
    byte[] data = mCrypto.encrypt(value.getBytes(CharsetsSupport.UTF_8), entity);

    mPreference.edit().putString(hashKey, Base64.encodeToString(data, Base64.NO_WRAP)).apply();
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:8,代码来源:PreferenceUtils.java


示例8: decryptPhoto

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
public Bitmap decryptPhoto(String filename) throws IOException, CryptoInitializationException, KeyChainException {
    FileInputStream fileStream = new FileInputStream(path + filename);
    InputStream inputStream = crypto.getCipherInputStream(fileStream, entity);
    Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
    inputStream.close();
    return bitmap;
}
 
开发者ID:kikoso,项目名称:DroidCon-Poland,代码行数:8,代码来源:CryptoManager.java


示例9: encrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
/**
 * Encrypts the unencrypted file. Can throw a lot of errors
 *
 * @param encrypted
 * @param unencrypted
 * @param entityName
 * @throws IOException
 * @throws CryptoInitializationException
 * @throws KeyChainException
 */
@Override
public void encrypt(File encrypted, File unencrypted,
                    String entityName) throws IOException, CryptoInitializationException, KeyChainException {
	doFileChecks(unencrypted, encrypted);

	FileInputStream from = new FileInputStream(unencrypted); // Stream to read from source
	OutputStream to = crypto.getCipherOutputStream(new FileOutputStream(encrypted),
			new Entity(entityName)); // Stream to write to destination

	copyStreams(from, to);
}
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:22,代码来源:ConcealCrypto.java


示例10: decrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
/**
 * Decrypts the encrypted file. Can also throw a lot of errors
 *
 * @param encrypted
 * @param unencrypted
 * @param entityName
 * @throws IOException
 * @throws CryptoInitializationException
 * @throws KeyChainException
 */
@Override
public void decrypt(File encrypted, File unencrypted,
                    String entityName) throws IOException, CryptoInitializationException, KeyChainException {
	doFileChecks(encrypted, unencrypted);

	InputStream from = crypto.getCipherInputStream(new FileInputStream(encrypted),
			new Entity(entityName));

	FileOutputStream to = new FileOutputStream(unencrypted);

	copyStreams(from, to);
}
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:23,代码来源:ConcealCrypto.java


示例11: deObscureFile

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
@RequiresPermission(allOf = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public File deObscureFile(File file,boolean deleteOldFile){
    if (enableCrypto) {
        try {
            if (file.getName().contains(DEFAULT_PREFIX_FILENAME)) {

                boolean isImage = FileUtils.isFileForImage(file);

                File mDecryptedFile = new File(makeDirectory() + file.getName().replace(DEFAULT_PREFIX_FILENAME,""));

                InputStream inputStream = crypto.getCipherInputStream(new FileInputStream(file), mEntityPassword);
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                OutputStream outputStream = new FileOutputStream(mDecryptedFile);
                BufferedInputStream bis = new BufferedInputStream(inputStream);
                int mRead;
                byte[] mBuffer = new byte[1024];
                while ((mRead = bis.read(mBuffer)) != -1) {
                    outputStream.write(mBuffer, 0, mRead);
                }
                bis.close();
                out.writeTo(outputStream);
                inputStream.close();
                outputStream.close();
                out.close();

                if (deleteOldFile)
                    file.delete();

                File pathDir = new File(isImage?makeImagesDirectory():makeFileDirectory());
                return FileUtils.moveFile(mDecryptedFile, pathDir);
            }

            return null;

        } catch (KeyChainException | CryptoInitializationException | IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    return file;
}
 
开发者ID:afiqiqmal,项目名称:ConcealSharedPreference-Android,代码行数:44,代码来源:ConcealCrypto.java


示例12: encrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
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);
}
 
开发者ID:izumin5210,项目名称:Sunazuri,代码行数:6,代码来源:EncryptionUtils.java


示例13: decrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
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);
}
 
开发者ID:izumin5210,项目名称:Sunazuri,代码行数:6,代码来源:EncryptionUtils.java


示例14: savePhotoEncrypted

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
public void savePhotoEncrypted(Bitmap imageBitmap, String filename) throws KeyChainException, CryptoInitializationException, IOException {
    FileOutputStream fileStream = new FileOutputStream(path + filename);
    OutputStream outputStream = crypto.getCipherOutputStream(fileStream, entity);
    imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
    outputStream.close();
}
 
开发者ID:kikoso,项目名称:DroidCon-Poland,代码行数:7,代码来源:CryptoManager.java


示例15: encrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
/**
 * Encrypts a file input stream to the given file
 * @param encrypted file to be written to. Cannot be a directory
 * @param unencrypted the original file to be encrypted
 * @exception java.io.IOException thrown when the operation fails, either because the encrypted
 * file already exists, or something failed during encryption
 */
public void encrypt(File encrypted, File unencrypted, String entityName) throws IOException, CryptoInitializationException, KeyChainException;
 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:9,代码来源:ICrypto.java


示例16: decrypt

import com.facebook.crypto.exception.CryptoInitializationException; //导入依赖的package包/类
public void decrypt(File encrypted, File unencrypted, String entityName) throws IOException, CryptoInitializationException, KeyChainException; 
开发者ID:droidstealth,项目名称:droid-stealth,代码行数:2,代码来源:ICrypto.java



注:本文中的com.facebook.crypto.exception.CryptoInitializationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageIn类代码示例发布时间:2022-05-22
下一篇:
Java DEREncodedKeyValue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap