mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-28 08:48:35 +00:00
allow storing private keys in the vault
This commit is contained in:
@@ -206,3 +206,31 @@ function utf8ToBytes (string, units) {
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
// Create lookup table for `toString('hex')`
|
||||
// See: https://github.com/feross/buffer/issues/219
|
||||
const hexSliceLookupTable = (function () {
|
||||
const alphabet = '0123456789abcdef'
|
||||
const table = new Array(256)
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
const i16 = i * 16
|
||||
for (let j = 0; j < 16; ++j) {
|
||||
table[i16 + j] = alphabet[i] + alphabet[j]
|
||||
}
|
||||
}
|
||||
return table
|
||||
})()
|
||||
|
||||
|
||||
export function hexSlice (start, end) {
|
||||
const len = this.length
|
||||
|
||||
if (!start || start < 0) {start = 0}
|
||||
if (!end || end < 0 || end > len) {end = len}
|
||||
|
||||
let out = ''
|
||||
for (let i = start; i < end; ++i) {
|
||||
out += hexSliceLookupTable[this[i]]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
Reference in New Issue
Block a user