base32 0.0.6

dart-base32

Simple base32 encode/decode matching the base32 method used by Google Authenticator.

Features:

Getting Started

Pubspec

pub.dartlang.org: (you can use 'any' instead of a version if you just want the latest always)

dependencies:
  base32: 0.0.6
#import('package:base32/base32.dart');

Start encoding/decoding ...

// Encode a hex string to base32
base32.encodeHexString('48656c6c6f21deadbeef'); // -> 'JBSWY3DPEHPK3PXP'

// base32 decoding to original string.
base32.decode("JBSWY3DPEHPK3PXP"); // -> '48656c6c6f21deadbeef'

API

base32.encode(List byteList)

Generate and return a RFC4122 v1 (timestamp-based) UUID.

  • byteList - (List) A list of bytes representing your input.

Returns String representation of the encoded base32.

base32.encodeHexString(String hex)

Generate and return a RFC4122 v4 UUID.

  • hexString - (String) A string of hex values intended to be converted to bytes and encoded.

Returns String representation of the encoded base32

Example: Encode a hex string.

base32.encodeHexString('48656c6c6f21deadbeef'); // -> 'JBSWY3DPEHPK3PXP'

base32.decode(String base32)

Decodes a base32 string back to its original byte values.

  • base32 - (String) The base32 string you wish to decode.

Returns Uint8List of the decoded data.

Example: Decode a base32 string, then output it in hex format

var decoded = base32.decode("JBSWY3DPEHPK3PXP");
var decodedHex = CryptoUtils.bytesToHex(decoded); // -> '48656c6c6f21deadbeef'

Testing

In dartvm

dart test\base32_test.dart

In Browser

At the moment, this package does not work client-side as it uses server-side only UInt8Lists. I might have to wait till UInt8Arrays and UInt8Lists are merged into 1

Release notes

v0.0.6 - Fix for language changes.

v0.0.5 - Fix for language changes.

v0.0.4 - Fixes and changes for M3 - New hex to byte converter.

v0.0.3 - Made all functions static.

v0.0.2 - Fixed unittest dependency

v0.0.1 - Initial Documented Release

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  base32: 0.0.6

If your package is an application package you should use any as the version constraint.

2. Install it

If you're using the Dart Editor, choose:

Menu > Tools > Pub Install

Or if you want to install from the command line, run:

$ pub install

3. Import it

Now in your Dart code, you can use:

import 'package:base32/base32.dart';
Version Uploaded Archive
0.0.6 Apr 11, 2013 Download base32 0.0.6 archive
0.0.5 Mar 03, 2013 Download base32 0.0.5 archive
0.0.4 Jan 22, 2013 Download base32 0.0.4 archive
0.0.3 Jan 03, 2013 Download base32 0.0.3 archive
0.0.2 Dec 14, 2012 Download base32 0.0.2 archive
0.0.1 Dec 14, 2012 Download base32 0.0.1 archive

About

Base32 Encoder and Decoder

Author

Email yulian@kuncheff.com Yulian Kuncheff

Homepage

https://github.com/Daegalus/dart-base32

Uploader

yulian@yuvaks.com

Share