|
52 | 52 | sha2/sha2-256
|
53 | 53 | (alphabase/byte-array-to-base (keyword output-format)))))
|
54 | 54 |
|
55 |
| -(defn ^:export sha2-256-js |
56 |
| - [& args] ; TS types don't work well with multi-arity fns |
57 |
| - (apply sha2-256 args)) |
58 |
| - |
59 | 55 | (defn ^:export sha2-256-normalize
|
60 | 56 | "sha2-256 hash of provided string after normalizing string."
|
61 | 57 | ([s] (sha2-256-normalize s :hex))
|
|
64 | 60 | normalize-string
|
65 | 61 | (sha2-256 output-format :string))))
|
66 | 62 |
|
67 |
| -(defn ^:export sha2-256-normalize-js |
68 |
| - [& args] ; TS types don't work well with multi-arity fns |
69 |
| - (apply sha2-256-normalize args)) |
70 |
| - |
71 | 63 | (defn ^:export sha2-512
|
72 | 64 | ([x] (sha2-512 x :hex))
|
73 | 65 | ([x output-format] (sha2-512 x output-format (coerce-input-format x)))
|
|
77 | 69 | sha2/sha2-512
|
78 | 70 | (alphabase/byte-array-to-base (keyword output-format)))))
|
79 | 71 |
|
80 |
| -(defn ^:export sha2-512-js |
81 |
| - [& args] ; TS types don't work well with multi-arity fns |
82 |
| - (apply sha2-512 args)) |
83 |
| - |
84 | 72 | (defn ^:export sha2-512-normalize
|
85 | 73 | "sha2-512 hash of provided string after normalizing string."
|
86 | 74 | ([s] (sha2-512-normalize s :hex))
|
|
89 | 77 | normalize-string
|
90 | 78 | (sha2-512 output-format :string))))
|
91 | 79 |
|
92 |
| -(defn ^:export sha2-512-normalize-js |
93 |
| - [& args] ; TS types don't work well with multi-arity fns |
94 |
| - (apply sha2-512-normalize args)) |
95 |
| - |
96 | 80 | (defn ^:export sha3-256
|
97 | 81 | ([x] (sha3-256 x :hex))
|
98 | 82 | ([x output-format] (sha3-256 x output-format (coerce-input-format x)))
|
|
102 | 86 | sha3/sha3-256
|
103 | 87 | (alphabase/byte-array-to-base (keyword output-format)))))
|
104 | 88 |
|
105 |
| -(defn ^:export sha3-256-js |
106 |
| - [& args] ; TS types don't work well with multi-arity fns |
107 |
| - (apply sha3-256 args)) |
108 |
| - |
109 | 89 | (defn ^:export sha3-256-normalize
|
110 | 90 | "sha3-256 hash of provided string after normalizing string."
|
111 | 91 | ([s] (sha3-256-normalize s :hex))
|
|
114 | 94 | normalize-string
|
115 | 95 | (sha3-256 output-format :string))))
|
116 | 96 |
|
117 |
| -(defn ^:export sha3-256-normalize-js |
118 |
| - [& args] ; TS types don't work well with multi-arity fns |
119 |
| - (apply sha3-256-normalize args)) |
120 |
| - |
121 | 97 | (defn ^:export sha3-512
|
122 | 98 | ([x] (sha3-512 x :hex))
|
123 | 99 | ([x output-format] (sha3-512 x output-format (coerce-input-format x)))
|
|
127 | 103 | sha3/sha3-512
|
128 | 104 | (alphabase/byte-array-to-base (keyword output-format)))))
|
129 | 105 |
|
130 |
| -(defn ^:export sha3-512-js |
131 |
| - [& args] ; TS types don't work well with multi-arity fns |
132 |
| - (apply sha3-512 args)) |
133 |
| - |
134 | 106 | (defn ^:export sha3-512-normalize
|
135 | 107 | "sha3-512 hash of provided string after normalizing string."
|
136 | 108 | ([s] (sha3-512-normalize s :hex))
|
|
139 | 111 | normalize-string
|
140 | 112 | (sha3-512 output-format :string))))
|
141 | 113 |
|
142 |
| -(defn ^:export sha3-512-normalize-js |
143 |
| - [& args] ; TS types don't work well with multi-arity fns |
144 |
| - (apply sha3-512-normalize args)) |
145 |
| - |
146 | 114 | (defn ^:export ripemd-160
|
147 | 115 | ([x] (ripemd-160 x :hex))
|
148 | 116 | ([x output-format] (ripemd-160 x output-format (coerce-input-format x)))
|
|
152 | 120 | ripemd/ripemd-160
|
153 | 121 | (alphabase/byte-array-to-base (keyword output-format)))))
|
154 | 122 |
|
155 |
| -(defn ^:export ripemd-160-js |
156 |
| - [& args] ; TS types don't work well with multi-arity fns |
157 |
| - (apply ripemd-160 args)) |
158 |
| - |
159 | 123 | (defn ^:export aes-encrypt
|
160 | 124 | ([x iv key] (aes-encrypt x iv key :hex))
|
161 | 125 | ([x iv key output-format]
|
162 | 126 | (aes/encrypt x key {:iv iv :output-format output-format})))
|
163 | 127 |
|
164 |
| -(defn ^:export aesEncrypt |
165 |
| - [& args] |
166 |
| - (apply aes-encrypt args)) |
167 |
| - |
168 | 128 | (defn ^:export aes-decrypt
|
169 | 129 | ([x iv key] (aes-decrypt x iv key :string :hex))
|
170 | 130 | ([x iv key output-format] (aes-decrypt x iv key output-format :hex))
|
171 | 131 | ([x iv key output-format input-format]
|
172 | 132 | (aes/decrypt x key {:iv iv :input-format input-format :output-format output-format})))
|
173 | 133 |
|
174 |
| -(defn ^:export aesDecrypt |
175 |
| - [& args] ; TS types don't work well with multi-arity fns |
176 |
| - (apply aes-decrypt args)) |
177 |
| - |
178 | 134 | (defn ^:export generate-key-pair
|
179 | 135 | ([] (secp256k1/generate-key-pair))
|
180 | 136 | ([private]
|
181 | 137 | (secp256k1/generate-key-pair private)))
|
182 | 138 |
|
183 |
| -#?(:cljs |
184 |
| - (defn ^:export generateKeyPair |
185 |
| - [& args] ; multi-arity fns don't play well with TS types |
186 |
| - (clj->js (apply generate-key-pair args)))) |
187 |
| - |
188 | 139 | (defn ^:export pub-key-from-private
|
189 | 140 | "Take a private key as either a hex string or BigInteger (clj) bignumber (cljs), returns as a hex string."
|
190 | 141 | [private-key]
|
|
252 | 203 | [jws]
|
253 | 204 | (jws/verify jws))
|
254 | 205 |
|
255 |
| -#?(:cljs |
256 |
| - (defn ^:export verifyJWS |
257 |
| - [jws] (clj->js (jws/verify jws)))) |
258 |
| - |
259 |
| - |
260 |
| -#?(:cljs |
261 |
| - (def ^:export js-exports |
262 |
| - #js {:normalizeString normalize-string |
263 |
| - :stringToByteArray string->byte-array |
264 |
| - :byteArrayToString byte-array->string |
265 |
| - :sha2_256 sha2-256-js |
266 |
| - :sha2_256_normalize sha2-256-normalize-js |
267 |
| - :sha2_512 sha2-512-js |
268 |
| - :sha2_512_normalize sha2-512-normalize-js |
269 |
| - :sha3_256 sha3-256-js |
270 |
| - :sha3_256_normalize sha3-256-normalize-js |
271 |
| - :sha3_512 sha3-512-js |
272 |
| - :sha3_512_normalize sha3-512-normalize-js |
273 |
| - :ripemd_160 ripemd-160-js |
274 |
| - :aesEncrypt aesEncrypt |
275 |
| - :aesDecrypt aesDecrypt |
276 |
| - :generateKeyPair generateKeyPair |
277 |
| - :pubKeyFromPrivate pub-key-from-private |
278 |
| - :accountIdFromPublic account-id-from-public |
279 |
| - :accountIdFromPrivate account-id-from-private |
280 |
| - :signMessage sign-message |
281 |
| - :verifySignature verify-signature |
282 |
| - :pubKeyFromMessage pub-key-from-message |
283 |
| - :accountIdFromMessage account-id-from-message |
284 |
| - :scryptEncrypt scrypt-encrypt |
285 |
| - :scryptCheck scrypt-check |
286 |
| - :randomBytes random-bytes |
287 |
| - :createJWS create-jws |
288 |
| - :verifyJWS verifyJWS})) |
289 |
| - |
290 | 206 | (comment
|
291 | 207 |
|
292 | 208 | (def kp (generate-key-pair))
|
|
380 | 296 | ;; CLJ + CLJS
|
381 | 297 | ;; "57f93bcf926c31a9e2d2129da84bfca51eb9447dfe1749b62598feacaad657d4"
|
382 | 298 |
|
383 |
| - (scrypt-check "hi" scrypt-hex mysalt 32768 8 1) |
| 299 | + (scrypt-check "hi" scrypt-hex mysalt 32768 8 1)) |
384 | 300 | ;; CLJ + CLJS
|
385 |
| - ) |
0 commit comments