(options: {
readonly user: string
readonly password: string
readonly salt: Uint8Array
})
| 92 | * @since 4.0.0 |
| 93 | */ |
| 94 | const md5PasswordUnsafe = (options: { |
| 95 | readonly user: string |
| 96 | readonly password: string |
| 97 | readonly salt: Uint8Array |
| 98 | }): string => { |
| 99 | if (options.salt.length !== 4) { |
| 100 | return fail(`PostgreSQL MD5 salt must be exactly 4 bytes, received ${options.salt.length}`) |
| 101 | } |
| 102 | const inner = createHash("md5").update(textEncoder.encode(options.password + options.user)).digest("hex") |
| 103 | const outer = createHash("md5").update(textEncoder.encode(inner)).update(options.salt).digest("hex") |
| 104 | return `md5${outer}` |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Computes the legacy PostgreSQL MD5 password response. |
no test coverage detected