Examples of DESEncrypter


Examples of com.encryption.DesEncrypter

    SecretKey key;
    try {
      key = KeyGenerator.getInstance("DES").generateKey();

      // Create encrypter/decrypter class
      DesEncrypter encrypter = new DesEncrypter(key);
      // Encrypt
      File encryptedFile = new File(uploadFile.getAbsolutePath() + ".des");
      encrypter.encrypt(new FileInputStream(uploadFile),
          new FileOutputStream(encryptedFile));

      /*
       * 利用公钥加密DES密钥
       */
 
View Full Code Here

Examples of com.encryption.DesEncrypter

     * 根据数据密钥,构造DesEncrypter对象
     */
    // Create encrypter/decrypter class
    SecretKeySpec key = new SecretKeySpec(dataKey, "DES");

    DesEncrypter decrypter = new DesEncrypter(key);

    /*
     * DesEncrypter对象调用解密模块,解密出原始文件
     */
    File decryptedFile = new File(file.getAbsolutePath() + ".dec");
    InputStream in = null;
    try {
      decrypter.decrypt(new FileInputStream(file), new FileOutputStream(
          decryptedFile));
      /*
       * 返回封装了原始文件的输入流
       */
      in = new FileInputStream(decryptedFile);
View Full Code Here

Examples of common.DESEncrypter

    } catch (Exception e) {
      e.printStackTrace();
    }

    // Create a DES encrypter
    desHelper = new DESEncrypter(key);
  }
View Full Code Here

Examples of common.DESEncrypter

      }
    } catch (Exception e) {
      e.printStackTrace();
      return 1;
    }
    crypt = new DESEncrypter(key);
    return 0;
  }
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

    protected Reader createReader(FileObject file) throws UnsupportedEncodingException, FileNotFoundException, FileSystemException {
       
        InputStream in = file.getContent().getInputStream();
       
        // If obfuscation enabled, use cipher to read code/metadata of script and tml deployments
        DESEncrypter cipher = getManager().getCipher();
        if (cipher != null && (getType() == WGDocument.TYPE_TML || getType() == WGDocument.TYPE_CSSJS)) {
            in = new CipherInputStream(in, cipher.getDcipher());
        }
              
        String encoding = getManager().getFileEncoding();
        // No more used because this creates a lot of problems with empty files
        // CharsetDecoder deco = Charset.forName(encoding).newDecoder();
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

            String configFilePath = retrieveConfigPath();
            // init DES-Encrypter
            File desKeyFile = new File(configFilePath, "des.key");

            desEncrypter = new DESEncrypter();
            try {
                try {
                    desEncrypter.init(desKeyFile);
                    log.info("DESEncrypter initialized using keyfile '" + desKeyFile.getPath() + "'.");
                }
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

    private void determineEncryption() throws WGDesignSyncException {
        try {
            FileObject file = getBaseFolder().resolveFile(DesignDirectory.OBFUSCATE_FLAGFILE);
            if (file.exists()) {
                _cipher = new DESEncrypter();
                _cipher.initObfuscation();
            }
        }
        catch (Exception e) {
            throw new WGDesignSyncException("Exception inizializing deobfuscation", e);
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

     private File _scriptDir;
     private boolean _obfuscate;

     public PluginISProvider(File designDirectory, boolean obfuscate) throws PersistentKeyException, GeneralSecurityException, IOException {
       if (obfuscate) {
         _cipher = new DESEncrypter();
       _cipher.initObfuscation();
       }
         _tmlDir = new File(designDirectory, DesignDirectory.FOLDERNAME_TML);
         _scriptDir = new File(designDirectory, DesignDirectory.FOLDERNAME_SCRIPT);
         _obfuscate = obfuscate;
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

     * @throws GeneralSecurityException
     * @throws IOException
     */
    public RSAEncryptedData encrypt(byte[] data) throws GeneralSecurityException, IOException {
        // create a tempoary desEncrypter with random desKEY
        DESEncrypter desEncrypter = new DESEncrypter();
        desEncrypter.init();       
      
        X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(RSAKeyPairUtils.getPublicKey(_keyPair));       
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        Cipher ecipher = Cipher.getInstance("RSA");       
        ecipher.init(Cipher.ENCRYPT_MODE, keyFactory.generatePublic(pubKeySpec));
       
        // encrypt desKey with rsaPubKey
        byte[] desKey = ecipher.doFinal(desEncrypter.getKey().getEncoded());       
       
        // encrypt data with des key
        String desData = desEncrypter.encrypt(data);
       
        return new RSAEncryptedData(Base64.encode(desKey), desData);
    }
View Full Code Here

Examples of de.innovationgate.utils.DESEncrypter

        DESKeySpec desKeySpec = new DESKeySpec(desKeyData);
        SecretKeyFactory desKeyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey desKey = desKeyFactory.generateSecret(desKeySpec);

        // create desEncrypter with decrypted desKey
        DESEncrypter desEncrypter = new DESEncrypter();
        desEncrypter.init(desKey);
       
        // decrypt data
        return desEncrypter.decrypt(input.getData());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.