🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
b

browser-string-hexer

A simple function for encoding a utf-8 string as a hex string.

1.0.0
latest
61

Supply Chain Security

100

Vulnerability

67

Quality

76

Maintenance

100

License

Version published
Maintainers
1
Created
Issues
0

Browser String Hexer

Take a string, get it as hex-encoded UTF-8 back!

Equivalent to the node operation of Buffer.from(YOUR_INPUT, 'utf8').toString('hex'), but in the browser, in one function.

You could just copy-paste it, it's very simple, but I realized that I hadn't shared this in a reusable form, and had taken for granted that I had Buffer in a browserify context in the past.

Useful for performing personal_sign invocations in MetaMask.

Installation

npm install browser-string-hexer or yarn add browser-string-hexer.

Usage

import hexer from 'browser-string-hexer';

const hex = hexer("hello");
// hex === '0x68656c6c6f'

FAQs

Package last updated on 30 Jan 2022

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