将一些代码从ruby openssl移植到java

将一些代码从ruby openssl移植到java,java,ruby,openssl,Java,Ruby,Openssl,我有以下资料: def from_code(code, secret) cipher = OpenSSL::Cipher::BF.new cipher.decrypt cipher.pkcs5_keyivgen(secret) data = cipher.update(Base64.decode64(code + "\n")) final = cipher.final plaintext = data + final plaintext end 我的目标是使用com

我有以下资料:

def from_code(code, secret)
  cipher = OpenSSL::Cipher::BF.new
  cipher.decrypt
  cipher.pkcs5_keyivgen(secret)
  data = cipher.update(Base64.decode64(code + "\n"))
  final = cipher.final
  plaintext = data + final
  plaintext
end
我的目标是使用commons.binary和javax.crypto(或者任何其他依赖项,这很好)实现完全相同的功能,但只使用Java。我在玩弄javax.crypto,但我想在这里问一下。
提前感谢。

您可以从java内部执行ruby代码:问题是openssl依赖关系。很难让这个gem在我的进程中可用,否则使用jruby就没问题了?Azolo:它很好,但我需要在现有的Java项目中使用这段代码,并且不知道如何在Java项目中打包jruby gem。