npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

secure-bits-encryption

v1.0.1

Published

Una biblioteca robusta y fácil de usar para la encriptación y desencriptación de datos.

Downloads

17

Readme

SecureBits Encryption

secure-bits-encryption es una biblioteca de encriptación robusta y fácil de usar que proporciona métodos para encriptar y desencriptar datos utilizando AES-GCM. Es perfecta para asegurar la confidencialidad de tus datos en aplicaciones web.

Instalación

Puedes instalar secure-bits-encryption usando npm:

npm install secure-bits-encryption

usando yarn:

yarn add secure-bits-encryption

Usar

Asegúrate de tener una clave ( base64Key) y un vector de inicialización ( base64Iv) en formato base64.

JavaScript puro

const SecureBits = require('secure-bits-encryption');

const base64Key = 'tu_clave_base64';
const base64Iv = 'tu_iv_base64';
const data = 'Mensaje secreto';

SecureBits.encryptSecurely(data, base64Key, base64Iv)
  .then(({ ciphertext, tag, iv }) => {
    console.log('Encrypted:', ciphertext, 'Tag:', tag, 'IV:', iv);

    SecureBits.decryptSecurely(ciphertext, tag, base64Key, iv)
      .then(decryptedData => {
        console.log('Decrypted:', decryptedData);
      })
      .catch(error => {
        console.error('Decryption failed:', error);
      });
  })
  .catch(error => {
    console.error('Encryption failed:', error);
  });

React

import React, { useState } from 'react';
import SecureBits from 'secure-bits-encryption';

const SecureComponent = () => {
  const base64Key = 'tu_clave_base64';
  const base64Iv = 'tu_iv_base64';
  const [message, setMessage] = useState('');
  const [encryptedData, setEncryptedData] = useState(null);
  const [decryptedData, setDecryptedData] = useState('');

  const handleEncrypt = async () => {
    try {
      const encrypted = await SecureBits.encryptSecurely(message, base64Key, base64Iv);
      setEncryptedData(encrypted);
      console.log('Encrypted:', encrypted);
    } catch (error) {
      console.error('Encryption failed:', error);
    }
  };

  const handleDecrypt = async () => {
    if (!encryptedData) return;
    try {
      const decrypted = await SecureBits.decryptSecurely(encryptedData.ciphertext, encryptedData.tag, base64Key, encryptedData.iv);
      setDecryptedData(decrypted);
      console.log('Decrypted:', decrypted);
    } catch (error) {
      console.error('Decryption failed:', error);
    }
  };

  return (
    <div>
      <input type="text" value={message} onChange={e => setMessage(e.target.value)} placeholder="Mensaje" />
      <button onClick={handleEncrypt}>Encriptar</button>
      {encryptedData && <p>Datos encriptados: {encryptedData.ciphertext}</p>}
      <button onClick={handleDecrypt} disabled={!encryptedData}>Desencriptar</button>
      {decryptedData && <p>Datos desencriptados: {decryptedData}</p>}
    </div>
  );
};

export default SecureComponent;

Vue

<template>
  <div>
    <input v-model="message" type="text" placeholder="Mensaje" />
    <button @click="handleEncrypt">Encriptar</button>
    <p v-if="encryptedData">Datos encriptados: {{ encryptedData.ciphertext }}</p>
    <button @click="handleDecrypt" :disabled="!encryptedData">Desencriptar</button>
    <p v-if="decryptedData">Datos desencriptados: {{ decryptedData }}</p>
  </div>
</template>

<script>
import SecureBits from 'secure-bits-encryption';

export default {
  data() {
    return {
      base64Key: 'tu_clave_base64',
      base64Iv: 'tu_iv_base64',
      message: '',
      encryptedData: null,
      decryptedData: ''
    };
  },
  methods: {
    async handleEncrypt() {
      try {
        this.encryptedData = await SecureBits.encryptSecurely(this.message, this.base64Key, this.base64Iv);
        console.log('Encrypted:', this.encryptedData);
      } catch (error) {
        console.error('Encryption failed:', error);
      }
    },
    async handleDecrypt() {
      if (!this.encryptedData) return;
      try {
        this.decryptedData = await SecureBits.decryptSecurely(this.encryptedData.ciphertext, this.encryptedData.tag, this.base64Key, this.encryptedData.iv);
        console.log('Decrypted:', this.decryptedData);
      } catch (error) {
        console.error('Decryption failed:', error);
      }
    }
  }
};
</script>

Mint Lang

component SecureComponent {
  state base64Key : String = "tu_clave_base64"
  state base64Iv : String = "tu_iv_base64"
  state message : String = ""
  state encryptedData : Maybe(String) = Nothing
  state decryptedData : String = ""

  fun encrypt() : Promise(Never, String) {
    SecureBits.encryptSecurely(message, base64Key, base64Iv)
      |> Promise.then((result : String) => {
          encryptedData = Just(result)
          Console.log("Encrypted: " + result)
        }, (error : Error) => {
          Console.error("Encryption failed: " + error.message)
        })
  }

  fun decrypt() : Promise(Never, String) {
    case encryptedData {
      Just(encrypted) => {
        SecureBits.decryptSecurely(encrypted, base64Key, base64Iv)
          |> Promise.then((result : String) => {
              decryptedData = result
              Console.log("Decrypted: " + result)
            }, (error : Error) => {
              Console.error("Decryption failed: " + error.message)
            })
      }
      Nothing => {
        Console.log("No data to decrypt")
      }
    }
  }

  fun render : Html {
    <div>
      <input type="text" value={message} onChange={message = event.target.value} placeholder="Mensaje" />
      <button onClick={encrypt}>Encriptar</button>
      {encryptedData != Nothing ? <p>{"Datos encriptados: " + encryptedData}</p> : ""}
      <button onClick={decrypt} disabled={encryptedData == Nothing}>Desencriptar</button>
      <p>{"Datos desencriptados: " + decryptedData}</p>
    </div>
  }
}

Contribuciones

Las contribuciones son siempre bienvenidas. Por favor, lee el CONTRIBUTING.md para obtener detalles sobre nuestro código de conducta, y el proceso para enviarnos pull requests.

Licencia

Este proyecto está bajo la Licencia [ISC]. Lee el archivo LICENSE para más detalles.

Si tienes alguna pregunta o necesitas soporte, no dudes en contactar al equipo de SecureBits Encryption o abrir un issue en el repositorio.

Contribuciones

Las contribuciones son siempre bienvenidas. Por favor, lee el CONTRIBUTING.md para obtener detalles sobre nuestro código de conducta, y el proceso para enviarnos pull requests.

Licencia

Este proyecto está bajo la Licencia [ISC]. Lee el archivo LICENSE para más detalles.

Si tienes alguna pregunta o necesitas soporte, no dudes en contactar al equipo de SecureBits o abrir un issue en el repositorio.