mirror of
https://github.com/logseq/logseq.git
synced 2026-05-25 05:04:24 +00:00
chore(rtc,e2ee): clear comments
This commit is contained in:
@@ -344,41 +344,3 @@
|
||||
(fn [e]
|
||||
(log/error "decrypt-text-by-text-password" e)
|
||||
(ex-info "decrypt-text-by-text-password" {} e)))))
|
||||
|
||||
(comment
|
||||
(let [array-buffers-equal?
|
||||
(fn [^js/ArrayBuffer buf1 ^js/ArrayBuffer buf2]
|
||||
(if (not= (.-byteLength buf1) (.-byteLength buf2))
|
||||
false
|
||||
(let [arr1 (js/Uint8Array. buf1)
|
||||
arr2 (js/Uint8Array. buf2)]
|
||||
(= (vec arr1) (vec arr2)))))]
|
||||
(p/let [rsa-key-pair (<generate-rsa-key-pair)
|
||||
aes-key (<generate-aes-key)
|
||||
public-key (:publicKey rsa-key-pair)
|
||||
private-key (:privateKey rsa-key-pair)
|
||||
encrypted-aes-key (<encrypt-aes-key public-key aes-key)
|
||||
decrypted-aes-key (<decrypt-aes-key private-key encrypted-aes-key)
|
||||
password "my-secret-password"
|
||||
encrypted-private-key (<encrypt-private-key password private-key)
|
||||
decrypted-private-key (<decrypt-private-key password encrypted-private-key)
|
||||
;; Export keys to compare their raw values
|
||||
exported-original-aes (.exportKey subtle "raw" aes-key)
|
||||
exported-decrypted-aes (.exportKey subtle "raw" decrypted-aes-key)
|
||||
exported-original-private (.exportKey subtle "pkcs8" private-key)
|
||||
exported-decrypted-private (.exportKey subtle "pkcs8" decrypted-private-key)
|
||||
;; Test text encryption
|
||||
original-text "This is a secret message."
|
||||
encrypted-text-data (<encrypt-text aes-key original-text)
|
||||
decrypted-text (<decrypt-text aes-key encrypted-text-data)]
|
||||
(js/console.log "Original AES key:" aes-key)
|
||||
(js/console.log "Decrypted AES key:" decrypted-aes-key)
|
||||
(js/console.log "Original private key:" private-key)
|
||||
(js/console.log "Decrypted private key:" decrypted-private-key)
|
||||
(let [aes-match? (array-buffers-equal? exported-original-aes exported-decrypted-aes)
|
||||
private-key-match? (array-buffers-equal? exported-original-private exported-decrypted-private)]
|
||||
(js/console.log "AES keys match:" aes-match?)
|
||||
(js/console.log "Private keys match:" private-key-match?))
|
||||
(js/console.log "Original text:" original-text)
|
||||
(js/console.log "Decrypted text:" decrypted-text)
|
||||
(js/console.log "Texts match:" (= original-text decrypted-text)))))
|
||||
|
||||
@@ -42,22 +42,11 @@
|
||||
(assert (and k @store))
|
||||
(idb-keyval/set k value @store))
|
||||
|
||||
(comment
|
||||
(defn- <remove-item!
|
||||
[k]
|
||||
(idb-keyval/del k @store)))
|
||||
|
||||
(defn- graph-encrypted-aes-key-idb-key
|
||||
[repo]
|
||||
(assert (some? repo))
|
||||
(str "rtc-encrypted-aes-key###" repo))
|
||||
|
||||
(comment
|
||||
(defn- user-rsa-key-pair-idb-key
|
||||
[user-uuid]
|
||||
(assert (some? user-uuid))
|
||||
(str "user-rsa-key-pair###" user-uuid)))
|
||||
|
||||
(defn- <import-public-key-transit-str
|
||||
"Return js/CryptoKey"
|
||||
[public-key-transit-str]
|
||||
|
||||
Reference in New Issue
Block a user