Merged in feature/wrap-logging (pull request #2511)
Feature/wrap logging * feat: change all logging to go through our own logger function so that we can control log levels * move packages/trpc to using our own logger * merge Approved-by: Linus Flood
This commit is contained in:
@@ -2,12 +2,15 @@ import "server-only"
|
||||
|
||||
import crypto from "crypto"
|
||||
|
||||
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
|
||||
|
||||
import { env } from "../../env/server"
|
||||
|
||||
const algorithm = "DES-ECB"
|
||||
const encryptionKey = env.BOOKING_ENCRYPTION_KEY
|
||||
const bufferKey = Buffer.from(encryptionKey, "utf8")
|
||||
|
||||
const encryptionLogger = createLogger("encryption")
|
||||
export function encrypt(originalString: string) {
|
||||
try {
|
||||
const cipher = crypto.createCipheriv(algorithm, bufferKey, null)
|
||||
@@ -25,7 +28,7 @@ export function encrypt(originalString: string) {
|
||||
const result = Buffer.concat(buffers).toString("base64")
|
||||
return result
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
encryptionLogger.error("encryption error", e)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -46,7 +49,7 @@ export function decrypt(encryptedString: string) {
|
||||
.replace(/(\x00)*/g, "")
|
||||
return result
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
encryptionLogger.error("decryption error", e)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user