-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
lambda/src/main/scala/pricemigrationengine/util/StringObfuscation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package pricemigrationengine.util | ||
import java.time.LocalDate | ||
|
||
object StringObfuscation { | ||
|
||
val string1: String = "0123456789AST-" // Do not edit this string! | ||
val string2: String = "456789AST0123&" // Do not edit this string! | ||
|
||
def obfuscate(x: Char): Char = { | ||
val index = string1.indexOf(x) | ||
if (index >= 0) { | ||
string2.charAt(index) | ||
} else { | ||
x | ||
} | ||
} | ||
|
||
def obfuscate(s: String): String = s.toList.map(obfuscate).mkString("") | ||
|
||
def recover(x: Char): Char = { | ||
val index = string2.indexOf(x) | ||
if (index >= 0) { | ||
string1.charAt(index) | ||
} else { | ||
x | ||
} | ||
} | ||
|
||
def recover(s: String): String = s.toList.map(recover).mkString("") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters