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


Java DesCrypt类代码示例

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


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

示例1: encryptValue

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
@Override
protected String encryptValue(EncryptMethod encryptMethod, SecretKey key, byte[] objBytes) throws GeneralException {
    byte[] saltBytes;
    switch (encryptMethod) {
        case SALT:
            Random random = new SecureRandom();
            // random length 5-16
            saltBytes = new byte[5 + random.nextInt(11)];
            random.nextBytes(saltBytes);
            break;
        default:
            saltBytes = new byte[0];
            break;
    }
    byte[] allBytes = new byte[1 + saltBytes.length + objBytes.length];
    allBytes[0] = (byte) saltBytes.length;
    System.arraycopy(saltBytes, 0, allBytes, 1, saltBytes.length);
    System.arraycopy(objBytes, 0, allBytes, 1 + saltBytes.length, objBytes.length);
    String result = Base64.encodeBase64String(DesCrypt.encrypt(key, allBytes));
    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:22,代码来源:EntityCrypto.java

示例2: EntityCrypto

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
public EntityCrypto(Delegator delegator, String kekText) throws EntityCryptoException {
    this.delegator = delegator;
    SecretKey kek;
    try {
        kek = UtilValidate.isNotEmpty(kekText) ? DesCrypt.getDesKey(Base64.decodeBase64(kekText)) : null;
    } catch (GeneralException e) {
        throw new EntityCryptoException(e);
    }
    handlers = new StorageHandler[] {
        new SaltedBase64StorageHandler(kek),
        NormalHashStorageHandler,
        OldFunnyHashStorageHandler,
    };
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:15,代码来源:EntityCrypto.java

示例3: decodeKeyBytes

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
@Override
protected byte[] decodeKeyBytes(String keyText) throws GeneralException {
    byte[] keyBytes = Base64.decodeBase64(keyText);
    if (kek != null) {
        keyBytes = DesCrypt.decrypt(kek, keyBytes);
    }
    return keyBytes;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:EntityCrypto.java

示例4: encodeKey

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
@Override
protected String encodeKey(SecretKey key) throws GeneralException {
    byte[] keyBytes = key.getEncoded();
    if (kek != null) {
        keyBytes = DesCrypt.encrypt(kek, keyBytes);
    }
    return Base64.encodeBase64String(keyBytes);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:EntityCrypto.java

示例5: decryptValue

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
@Override
protected byte[] decryptValue(SecretKey key, String encryptedString) throws GeneralException {
    byte[] allBytes = DesCrypt.decrypt(key, Base64.decodeBase64(encryptedString));
    int length = allBytes[0];
    byte[] objBytes = new byte[allBytes.length - 1 - length];
    System.arraycopy(allBytes, 1 + length, objBytes, 0, objBytes.length);
    return objBytes;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:9,代码来源:EntityCrypto.java

示例6: encryptValue

import org.ofbiz.base.crypto.DesCrypt; //导入依赖的package包/类
@Override
protected String encryptValue(SecretKey key, byte[] objBytes) throws GeneralException {
    Random random = new Random();
    // random length 5-16
    byte[] saltBytes = new byte[5 + random.nextInt(11)];
    random.nextBytes(saltBytes);
    byte[] allBytes = new byte[1 + saltBytes.length + objBytes.length];
    allBytes[0] = (byte) saltBytes.length;
    System.arraycopy(saltBytes, 0, allBytes, 1, saltBytes.length);
    System.arraycopy(objBytes, 0, allBytes, 1 + saltBytes.length, objBytes.length);
    String result = Base64.encodeBase64String(DesCrypt.encrypt(key, allBytes));
    return result;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:14,代码来源:EntityCrypto.java


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