How to use the lzutf8.compress function in lzutf8

To help you get started, we’ve selected a few lzutf8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blockkeeper / blockkeeper-frontend-web / src / logic / Core.js View on Github external
async encrypt (pld, secrets) {
    try {
      let rawPld
      try {
        rawPld = LZUTF8.compress(JSON.stringify(pld))
      } catch (e) {
        throw this.err('Packing process failed', { e })
      }
      try {
        secrets = await this.loadSecrets(['encrypt'], secrets)
        const tagSize = 128 // 128 bits
        const iv = new Uint8Array(12) // 12 bytes
        crypto.getRandomValues(iv)
        let cypher = await crypto.subtle.encrypt(
          {
            name: 'AES-GCM',
            iv,
            tagLength: tagSize,
            additionalData: __.strToArrBuf(secrets.userId)
          },
          secrets.cryptKeyObj,
github RossMcMillan92 / djent / src / generic / scripts / app / components / ShareController.js View on Github external
getShareableURL = (preset) => {
        const compressedPreset = compress(JSON.stringify(preset), { outputEncoding: 'Base64' })
        const shareableURL = `djen.co/#share=${compressedPreset}`
        if (shareableURL.length > 2048) logError('URL exceeds 2048 chars. May not succeed')
        return shareableURL
    }
github nicolaschan / bell / src / CookieSerializer.js View on Github external
serialize (value) {
    return LZUTF8.compress(JSON.stringify(value), {
      outputEncoding: 'BinaryString'
    })
  }
github ralscha / blog / pwmanager / client / src / app / password.service.ts View on Github external
private async encrypt(): Promise {
    const compressed = LZUTF8.compress(JSON.stringify([...this.passwords]));

    const initializationVector = new Uint8Array(this.ivLen);
    crypto.getRandomValues(initializationVector);

    const encrypted = await crypto.subtle.encrypt({
        name: 'AES-GCM',
        iv: initializationVector
      },
      this.masterKey,
      compressed
    );

    return this.concatUint8Array(initializationVector, new Uint8Array(encrypted));
  }
github yDgunz / gunswap / src / ui / Animator.tsx View on Github external
private updatePattern(pattern : Pattern, patternSettings: PatternSettings) {
		
		var patternSettingsQueryString = encodeURIComponent(lzutf8.compress(JSON.stringify(patternSettings),{outputEncoding: "Base64"}));
		window.history.pushState('pattern', 'pattern', window.location.origin + window.location.pathname + '?patternSettings=' + patternSettingsQueryString);
		this.setState({pattern: pattern, patternSettings: patternSettings});		
	}
github RossMcMillan92 / djent / src / generic / scripts / app / containers / ShareController.js View on Github external
require.ensure(['lzutf8'], (require) => {
            const compress = require('lzutf8').compress
            const compressedPreset = compress(JSON.stringify(preset), { outputEncoding: 'Base64' })
            const shareableURL = `djen.co/#share=${compressedPreset}`
            if (shareableURL.length > 2048) logError('URL exceeds 2048 chars. May not succeed')
            res(shareableURL)
        }, 'lzutf8')
    })

lzutf8

A high-performance string compression library

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis