-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smart ID Creation Smart Id Hex 90% Intigrated Smaller Client Connection Id Default Server-Client Connection Id size CharSet header for toString for specific decoding
- Loading branch information
1 parent
16eb39d
commit cf212dc
Showing
14 changed files
with
133 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Benchmark from 'benchmark'; | ||
import { hasValue } from '@universalweb/acid'; | ||
import { randomConnectionId } from '#utilities/crypto'; | ||
const eight = 8; | ||
export function generateConnectionId(size = eight, prepend) { | ||
const characters = 'abcdef0123456789'; | ||
let result = ''; | ||
const charactersLength = characters.length; | ||
const hexSize = size * 2; | ||
for (let i = 0; i < hexSize; i++) { | ||
const randomIndex = Math.floor(Math.random() * charactersLength); | ||
result += characters.charAt(randomIndex); | ||
} | ||
if (hasValue(prepend)) { | ||
result = `${prepend}${result.substring(prepend.length)}`; | ||
} | ||
return result; | ||
} | ||
export function connectionIdToBuffer(source) { | ||
return Buffer.from(source, 'hex'); | ||
} | ||
export function connectionIdToString(source) { | ||
return source.toString('hex'); | ||
} | ||
export function getConnectionIdReservedSpace(source, size) { | ||
return source.subarray(0, size); | ||
} | ||
export function getConnectionIdReservedSpaceString(source, size) { | ||
return source.subarray(0, size).toString('hex'); | ||
} | ||
// const serverConnectionIdString = generateConnectionId(8, '01'); | ||
// console.log(connectionIdToBuffer(serverConnectionIdString).toString('hex'), connectionIdToBuffer(serverConnectionIdString).length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.