mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 02:09:38 +02:00
WIP: Tinkering with CRLF encoding
This commit is contained in:
parent
bfdbac0f2d
commit
dd41922762
2 changed files with 31 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
package org.pgpainless.decryption_verification
|
package org.pgpainless.decryption_verification
|
||||||
|
|
||||||
import java.io.EOFException
|
import java.io.EOFException
|
||||||
|
import java.io.FilterInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
@ -18,6 +19,7 @@ import org.bouncycastle.openpgp.PGPCompressedData
|
||||||
import org.bouncycastle.openpgp.PGPEncryptedData
|
import org.bouncycastle.openpgp.PGPEncryptedData
|
||||||
import org.bouncycastle.openpgp.PGPEncryptedDataList
|
import org.bouncycastle.openpgp.PGPEncryptedDataList
|
||||||
import org.bouncycastle.openpgp.PGPException
|
import org.bouncycastle.openpgp.PGPException
|
||||||
|
import org.bouncycastle.openpgp.PGPLiteralData
|
||||||
import org.bouncycastle.openpgp.PGPOnePassSignature
|
import org.bouncycastle.openpgp.PGPOnePassSignature
|
||||||
import org.bouncycastle.openpgp.PGPPBEEncryptedData
|
import org.bouncycastle.openpgp.PGPPBEEncryptedData
|
||||||
import org.bouncycastle.openpgp.PGPPrivateKey
|
import org.bouncycastle.openpgp.PGPPrivateKey
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.pgpainless.decryption_verification
|
||||||
|
|
||||||
|
import org.bouncycastle.util.io.Streams
|
||||||
|
import org.junit.jupiter.api.Assertions.assertArrayEquals
|
||||||
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class CRLFInputStreamTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun readRNOneByOne() {
|
||||||
|
val bIn = "a\r\nb".byteInputStream()
|
||||||
|
val crlfIn = OpenPgpMessageInputStream.CRLFInputStream(bIn)
|
||||||
|
|
||||||
|
assertEquals('a'.code, crlfIn.read())
|
||||||
|
assertEquals('\n'.code, crlfIn.read())
|
||||||
|
assertEquals('b'.code, crlfIn.read())
|
||||||
|
assertEquals(-1, crlfIn.read())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun readRNAtOnce() {
|
||||||
|
val bIn = "a\r\nb".byteInputStream()
|
||||||
|
val crlfIn = OpenPgpMessageInputStream.CRLFInputStream(bIn)
|
||||||
|
|
||||||
|
val bytes = Streams.readAll(crlfIn)
|
||||||
|
assertArrayEquals("a\nb".toByteArray(), bytes)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue