当前位置: 首页>>代码示例>>Java>>正文


Java Entity.create方法代码示例

本文整理汇总了Java中com.facebook.crypto.Entity.create方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.create方法的具体用法?Java Entity.create怎么用?Java Entity.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.crypto.Entity的用法示例。


在下文中一共展示了Entity.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
public ConcealCrypto create(){

            if (this.context == null){
                throw new RuntimeException("Context cannot be null");
            }

            mEntityPassword = Entity.create(CipherUtils.obscureEncodeSixFourString(mEntityPasswordRaw.getBytes()));
            makeKeyChain = new SharedPrefsBackedKeyChain(this.context.get(),(mKeyChain==null)?CryptoConfig.KEY_256:mKeyChain);

            if (mKeyChain == null) {
                crypto = AndroidConceal.get().createDefaultCrypto(makeKeyChain);
            } else if (mKeyChain == CryptoConfig.KEY_128) {
                crypto = AndroidConceal.get().createCrypto128Bits(makeKeyChain);
            } else {
                crypto = AndroidConceal.get().createCrypto256Bits(makeKeyChain);
            }

            return new ConcealCrypto(this);
        }
 
开发者ID:afiqiqmal,项目名称:ConcealSharedPreference-Android,代码行数:20,代码来源:ConcealCrypto.java

示例2: encrypt

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
@Override
public String encrypt(String data) {
    long startTime = System.currentTimeMillis();
    ESLog.v("%s=>encrypt(%s)", getClass().getSimpleName(), data);

    try {
        Entity entity = Entity.create(getEntityName());
        byte[] encrypted = crypto.encrypt(data.getBytes(SSCharset.CHARSET), entity);

        ESLog.v("Encryption millis time: %d", System.currentTimeMillis() - startTime);

        return encoding.toBase64(encrypted);
    } catch (Exception e) {
        ESLog.wtf("Something went wrong %s", e.getCause());
        throw new UnexpectedEncryptionException(e);
    }
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:18,代码来源:ICSNativeStringEncryption.java

示例3: decrypt

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
@Override
public String decrypt(String data) {
    long startTime = System.currentTimeMillis();
    ESLog.v("%s=>decrypt(%s)", getClass().getSimpleName(), data);

    try {
        Entity entity = Entity.create(getEntityName());
        byte[] decodedData = encoding.fromBase64ToBytes(data);
        byte[] decrypted = crypto.decrypt(decodedData, entity);

        ESLog.v("Decryption millis time: %d", System.currentTimeMillis() - startTime);

        return new String(decrypted);
    } catch (Exception e) {
        ESLog.wtf("Something went wrong %s", e.getCause());
        throw new UnexpectedDecryptionException(e);
    }
}
 
开发者ID:marius-bardan,项目名称:encryptedprefs,代码行数:19,代码来源:ICSNativeStringEncryption.java

示例4: get

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
public <T> T get(@NonNull String key, Type type) {
    T value = null;
    try {
        String hashKey = CommonCrypto.hashPrefKey(key);
        String old = mPreference.getString(hashKey, null);
        if (old != null) {
            Entity entity = Entity.create(key);
            byte[] data = mCrypto.decrypt(Base64.decode(old, Base64.NO_WRAP), entity);
            value = mGson.fromJson(new String(data, CharsetsSupport.UTF_8), type);
        }
    } catch (Exception e) {
        Timber.w(e);
        return null;
    }
    return value;
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:17,代码来源:PreferenceUtils.java

示例5: ConcealStringSetPreference

import com.facebook.crypto.Entity; //导入方法依赖的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);
}
 
开发者ID:prolificinteractive,项目名称:Patrons,代码行数:10,代码来源:ConcealStringSetPreference.java

示例6: ConcealStringPreference

import com.facebook.crypto.Entity; //导入方法依赖的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);
}
 
开发者ID:prolificinteractive,项目名称:Patrons,代码行数:10,代码来源:ConcealStringPreference.java

示例7: build

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
public SharedPreferences build() {
    if(!isInit) {
        Log.w(TAG, "You need call 'SecurePreferences.init()' in onCreate() from your application class.");
    }
    KeyChain keyChain = new SharedPrefsBackedKeyChain(context, CryptoConfig.KEY_256);
    Entity entity = Entity.create(
            TextUtils.isEmpty(password) ? getClass().getPackage().getName() : password
    );
    return new SecurePreferences(
            context,
            keyChain,
            entity,
            sharedPrefFilename
    );
}
 
开发者ID:KaKaVip,项目名称:secure-preferences,代码行数:16,代码来源:SecurePreferences.java

示例8: decrypt

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
public String decrypt(String key, String value, Type type) throws CryptoException {
    try {
        Entity entity = Entity.create(key);
        byte[] data = mFbCrypto.decrypt(Base64.decode(value, Base64.NO_WRAP), entity);
        return mGson.fromJson(new String(data, CharsetsSupport.UTF_8), type);
    } catch (Exception e) {
        throw new CryptoException(e);
    }
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:10,代码来源:PropertyCrypto.java

示例9: decrypt

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
@Override
public String decrypt(String key, String value) throws Exception {
    Entity entity = Entity.create(key);
    byte[] decodedBytes = Base64.decode(value, Base64.NO_WRAP);
    byte[] bytes = crypto.decrypt(decodedBytes, entity);
    return new String(bytes);
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:8,代码来源:BeeEncryption.java

示例10: put

import com.facebook.crypto.Entity; //导入方法依赖的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

示例11: testConceal

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
@Test public void testConceal() throws Exception {
  Entity entity = Entity.create("key");
  String value = "value";
  byte[] encryptedValue = crypto.encrypt(value.getBytes(), entity);

  assertThat(encryptedValue).isNotNull();

  String decryptedValue = new String(crypto.decrypt(encryptedValue, entity));
  assertThat(decryptedValue).isEqualTo("value");
}
 
开发者ID:orhanobut,项目名称:hawk,代码行数:11,代码来源:ConcealTest.java

示例12: setEntityPassword

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
public void setEntityPassword(String password) {
    if (password!=null)this.mEntityPassword = Entity.create(CipherUtils.obscureEncodeSixFourString(password.getBytes()));
}
 
开发者ID:afiqiqmal,项目名称:ConcealSharedPreference-Android,代码行数:4,代码来源:ConcealCrypto.java

示例13: encrypt

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
@Override
public String encrypt(String key, String value) throws Exception {
    Entity entity = Entity.create(key);
    byte[] bytes = crypto.encrypt(value.getBytes(), entity);
    return Base64.encodeToString(bytes, Base64.NO_WRAP);
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:7,代码来源:BeeEncryption.java

示例14: createUsernameEntity

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
private Entity createUsernameEntity(String service) {
    String prefix = getEntityPrefix(service);
    return Entity.create(prefix + "user");
}
 
开发者ID:oblador,项目名称:react-native-keychain,代码行数:5,代码来源:CipherStorageFacebookConceal.java

示例15: createPasswordEntity

import com.facebook.crypto.Entity; //导入方法依赖的package包/类
private Entity createPasswordEntity(String service) {
    String prefix = getEntityPrefix(service);
    return Entity.create(prefix + "pass");
}
 
开发者ID:oblador,项目名称:react-native-keychain,代码行数:5,代码来源:CipherStorageFacebookConceal.java


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