简体   繁体   English

使用 AES 256 在 Scala/Java 中加密文件

[英]Encrypt a file in Scala/Java using AES 256

I want to use symmetric encyption[AES -256] to encrypt and decrypt a [.dat] file using a secret key file provided to me from a team which they created using open ssl commands.我想使用对称加密 [AES -256] 使用他们使用开放 ssl 命令创建的团队提供给我的密钥文件来加密和解密 [.dat] 文件。

I am unable to find right examples to understand how to use the file already provided to me to encrypt and decrypt instead of generating a new key for the process in Scala.我无法找到正确的示例来了解如何使用已经提供给我的文件来加密和解密,而不是为 Scala 中的过程生成新密钥。

Any help and guidance is appreciated.任何帮助和指导表示赞赏。

You can use the Bouncy Castle library for that.您可以为此使用 Bouncy Castle 库。 Here'sa lightweight example listed on their website:这是他们网站上列出的轻量级示例:

https://www.bouncycastle.org/specifications.html (section 5 & 5.1). https://www.bouncycastle.org/specifications.html (第 5 和 5.1 节)。

You can specify AES as encryption algorithm via the Engine (see section 5.2).您可以通过引擎指定 AES 作为加密算法(参见第 5.2 节)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM