diff options
Diffstat (limited to 'src/utils/CryptoUtils.scala')
-rw-r--r-- | src/utils/CryptoUtils.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/CryptoUtils.scala b/src/utils/CryptoUtils.scala index 6c2849e..54e5034 100644 --- a/src/utils/CryptoUtils.scala +++ b/src/utils/CryptoUtils.scala @@ -11,4 +11,12 @@ object CryptoUtils { s ++ Stream.continually(padLength.toByte).take(padLength) } + def stripPkcs7Pad(s: Seq[Byte]): Seq[Byte] = + s.dropRight(s.last) + + def cbcEncrypt(builder: CbcBuilder)(data: Seq[Byte]) = + builder.encrypt.end(data) + + def cbcDecrypt(builder: CbcBuilder)(data: Seq[Byte]) = + stripPkcs7Pad(builder.decrypt.end(data)) } |