20 lines
536 B
Clojure
20 lines
536 B
Clojure
(ns status-im.utils.security)
|
|
|
|
(defprotocol Unmaskable
|
|
;; Retrieve the stored value.
|
|
(unmask [this]))
|
|
|
|
;; MaskedData ensures that the object passed to it won't be occasionally printed
|
|
;; via println or log functions. Useful for keeping sensitive data, such as passwords
|
|
;; to avoid accidentally exposing them.
|
|
(deftype MaskedData [data]
|
|
Object
|
|
(toString [_] "******")
|
|
Unmaskable
|
|
(unmask [this]
|
|
(.-data this)))
|
|
|
|
;; Returns a MaskedData instance that stores the piece of data.
|
|
(defn mask-data [data]
|
|
(MaskedData. data))
|