1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Do not trim passphrases automatically

This commit is contained in:
Paul Schaub 2025-07-23 11:24:10 +02:00
parent 0ee31b232a
commit 9b0a3cd4c7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -11,14 +11,9 @@ import org.bouncycastle.util.Arrays
* *
* @param chars may be null for empty passwords. * @param chars may be null for empty passwords.
*/ */
class Passphrase(chars: CharArray?) { class Passphrase(private val chars: CharArray?) {
private val lock = Any() private val lock = Any()
private var valid = true private var valid = true
private val chars: CharArray?
init {
this.chars = trimWhitespace(chars)
}
/** /**
* Return a copy of the underlying char array. A return value of null represents an empty * Return a copy of the underlying char array. A return value of null represents an empty
@ -67,6 +62,13 @@ class Passphrase(chars: CharArray?) {
override fun hashCode(): Int = getChars()?.let { String(it) }.hashCode() override fun hashCode(): Int = getChars()?.let { String(it) }.hashCode()
/**
* Return a copy of this [Passphrase], but with whitespace characters trimmed off.
*
* @return copy with trimmed whitespace
*/
fun withTrimmedWhitespace(): Passphrase = Passphrase(trimWhitespace(chars))
companion object { companion object {
/** /**