File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,15 @@ <h4>Sub-Account Generator</h4>
144
144
< div type ="text " class ="form-control " id ="subid-subid "> Sub-Account
145
145
</ div >
146
146
</ div >
147
+ < h4 > u8 Array to Hex</ h4 >
148
+ < div class ="input-group ">
149
+ < input type ="text " class ="form-control " id ="u8a-u82h "
150
+ placeholder ="Comma Separated u8a Array ">
151
+ < div class ="input-group-prepend ">
152
+ < span class ="input-group-text " id ="addon-wrapping "> ⇄</ span >
153
+ </ div >
154
+ < input type ="text " class ="form-control " id ="hex-u82h " placeholder ="Hex ">
155
+ </ div >
147
156
</ div >
148
157
</ div >
149
158
</ div >
Original file line number Diff line number Diff line change @@ -273,3 +273,34 @@ function subAccountId() {
273
273
console . error ( e ) ;
274
274
}
275
275
}
276
+
277
+ /* u8a to Hex */
278
+ let u82h = {
279
+ "u8a" : document . getElementById ( "u8a-u82h" ) ,
280
+ "hex" : document . getElementById ( "hex-u82h" )
281
+ } ;
282
+
283
+ u82h . u8a . addEventListener ( "input" , u8a2hex ) ;
284
+ u82h . hex . addEventListener ( "input" , hex2u8a ) ;
285
+
286
+ function u8a2hex ( ) {
287
+ try {
288
+ let array = u82h . u8a . value . replace ( / / g, "" ) . split ( "," ) . filter ( e => e ) ;
289
+ let u8array = new Uint8Array ( array ) ;
290
+ u82h . hex . value = u8aToHex ( u8array ) ;
291
+ } catch ( e ) {
292
+ u82h . hex . value = "Error" ;
293
+ console . error ( e ) ;
294
+ }
295
+ }
296
+
297
+ function hex2u8a ( ) {
298
+ try {
299
+ let array = u82h . hex . value . match ( / .{ 1 , 2 } / g) . map ( byte => parseInt ( byte , 16 ) ) ;
300
+ let u8a = new Uint8Array ( array ) ;
301
+ u82h . u8a . value = u8a ;
302
+ } catch ( e ) {
303
+ u82h . hex . value = "Error" ;
304
+ console . error ( e ) ;
305
+ }
306
+ }
You can’t perform that action at this time.
0 commit comments