Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crypted.toBase64 #17

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypto/src/main/scala/uk/gov/hmrc/crypto/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ case class PlainBytes(value: Array[Byte]) extends PlainContent

case class Crypted(value: String) {
def toBase64 =
Base64.getDecoder.decode(value.getBytes("UTF-8"))
Base64.getEncoder.encode(value.getBytes("UTF-8"))
}

object Crypted extends (String => Crypted) {
Expand Down
29 changes: 29 additions & 0 deletions crypto/src/test/scala/uk/gov/hmrc/crypto/ModelSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2022 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.hmrc.crypto

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

class ModelSpec extends AnyWordSpecLike with Matchers {
"Crypted" should {
"encode and decode Base64" in {
val encrypted = Crypted("")
Crypted.fromBase64(new String(encrypted.toBase64)).value shouldBe encrypted.value
}
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.8
sbt.version=1.6.2
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.7.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.8.0")