MCPcopy Create free account
hub / github.com/cameri/nostream / calcPaddedLen

Function calcPaddedLen

src/utils/nip44.ts:63–70  ·  view source on GitHub ↗
(unpaddedLen: number)

Source from the content-addressed store, hash-verified

61}
62
63function calcPaddedLen(unpaddedLen: number): number {
64 if (unpaddedLen <= 32) {
65 return 32
66 }
67 const nextPower = 1 << (Math.floor(Math.log2(unpaddedLen - 1)) + 1)
68 const chunk = nextPower <= 256 ? 32 : nextPower / 8
69 return chunk * (Math.floor((unpaddedLen - 1) / chunk) + 1)
70}
71
72function pad(plaintext: string): Buffer {
73 const unpadded = Buffer.from(plaintext, 'utf8')

Callers 2

padFunction · 0.85
unpadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected