解密加密文件并在Java中执行 [英] Decrypting an encrypted file and executing in Java

查看:103
本文介绍了解密加密文件并在Java中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在一个可以对文件进行加密和解密的项目。我正在用Java开发它。



这是它的工作原理(简化):


  1. 首先,我读取文件并将其转换为字节数组

  2. 然后我加密字节数组并将其写回文件

当我想要运行加密文件时,我做的相反,就像这样:


  1. 我读取加密文件并将其转换为字节数组

  2. 然后我解密字节数组并将其写回文件。

所以文件被转换回原来的形式。



我的问题是,我不想将解密的字节数组作为文件写入磁盘。



通过运行它,我的意思是执行它,因为它是一个Win32可执行命令。



提前感谢
Onur

解决方案

我会说你的选择在这里是有限的,因为你依赖Windows开始这个过程。 Java是跨平台的,可能无法以您想要的方式挂接到Windows中。



在纯Java领域之外,您可以创建一个ramdisk,并将EXE写入Ramdisk,或者跨桥到.NET,如这个答案(和答案内的问题链接)。


I am currently working on a project where i can encrypt and decrypt files. I am developing it in Java.

This is how it works (simplified):

  1. First I read the file and convert it to a byte array
  2. Then I encrypt the byte array and write it back to a file

When I want to run the encrypted file, I do the opposite, so like this:

  1. I read encrypted file and convert it to byte array
  2. Then I decrypt the byte array and write it back to a file.

So the file is converted back to its original form.

My problem is, I do not want to write the decrypted byte array as a file to the disk.

Is there a way to do this? I want to run the decrypted byte array directly in memory. By "running" it, I mean executing it, because it is a Win32 executable crypter.

Thanks in advance, Onur

解决方案

I'd say that your options are limited here, because you are dependent on Windows starting the process. Java, being cross-platform, probably doesn't have the ability to hook into Windows in the way you want.

Straying outside the realms of pure Java, you could create a ramdisk and write the EXE to the Ramdisk, or perhaps bridge across to .NET, as described in this answer (and question links inside that answer).

这篇关于解密加密文件并在Java中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆