當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。