browser-string-hexer

1.0.0 • Public • Published

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'

Readme

Keywords

none

Package Sidebar

Install

npm i browser-string-hexer

Weekly Downloads

145

Version

1.0.0

License

MIT

Unpacked Size

6.85 kB

Total Files

4

Last publish

Collaborators

  • danfinlay