Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tweetnacl-util

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tweetnacl-util

String encoding utilitlies extracted from TweetNaCl.js

  • 0.15.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is tweetnacl-util?

The tweetnacl-util npm package provides utility functions for encoding and decoding data to and from various formats, such as Base64 and UTF-8, which are commonly used in cryptographic operations. It is a companion to the tweetnacl package, which is a cryptographic library.

What are tweetnacl-util's main functionalities?

Encoding to Base64

This feature allows you to encode a UTF-8 string into a Base64 string. This is useful for encoding data that needs to be transmitted over media that are designed to deal with textual data.

const naclUtil = require('tweetnacl-util');
const message = 'Hello, World!';
const encodedMessage = naclUtil.encodeBase64(naclUtil.decodeUTF8(message));
console.log(encodedMessage);

Decoding from Base64

This feature allows you to decode a Base64 string back into a UTF-8 string. This is useful for decoding data that was encoded for safe transmission over text-based protocols.

const naclUtil = require('tweetnacl-util');
const encodedMessage = 'SGVsbG8sIFdvcmxkIQ==';
const decodedMessage = naclUtil.encodeUTF8(naclUtil.decodeBase64(encodedMessage));
console.log(decodedMessage);

Encoding to UTF-8

This feature allows you to encode a string into a UTF-8 byte array. This is useful for preparing data for cryptographic operations that require byte arrays.

const naclUtil = require('tweetnacl-util');
const message = 'Hello, World!';
const utf8Bytes = naclUtil.decodeUTF8(message);
console.log(utf8Bytes);

Decoding from UTF-8

This feature allows you to decode a UTF-8 byte array back into a string. This is useful for converting data back into a human-readable format after cryptographic operations.

const naclUtil = require('tweetnacl-util');
const utf8Bytes = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]);
const message = naclUtil.encodeUTF8(utf8Bytes);
console.log(message);

Other packages similar to tweetnacl-util

Keywords

FAQs

Package last updated on 29 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc