1

I'm trying to create an NFC based communication between my phone and my pc using an arduino. For that I implemented an service in java which provides an Input- and OutputStream for binary based communication. To encrypt the communication I'm using the C# SslStream on my pc to act as server. It can be created with any stream type (not only tcp). Does java also has an equivalent because its SSLSocket seems to work with tcp based communication only, doesn't it? I just want to use the Input- and OutputStream and encrypt the communication.

thanks in advance

HYMXDEV
  • 283
  • 3
  • 9
  • 1
    check [SSLEngine](https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLEngine.html). [Here](https://examples.javacodegeeks.com/core-java/nio/java-nio-ssl-example/) is an example using NIO and SSLEngine. Similar discussion [here](http://stackoverflow.com/questions/9118367/java-nio-channels-and-tls). – andreim May 11 '17 at 19:13

1 Answers1

0

You can use CipherInputStream and CipherOutputStream to enrypt Input and Output stream respectively. Both of these classes have constructors that accept InputStream and OutputStream so you can initialise these from existing streams.

Here is an example of how to encrypt/derypt the streams using Cipher and Key.

Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102