패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.2.0

base32

Dart용 Base32 인코더 및 디코더로, 주로 일회용 암호 비밀번호에 사용됩니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
18.1만
좋아요
29
Pub 점수
160

패키지 설치

flutter pub add base32

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Base32 알고리즘을 사용하여 데이터를 인코딩하고 디코딩하기 위한 Dart 패키지로, 일회용 비밀번호(OTP) 시크릿을 안전하게 처리하도록 설계되었습니다. RFC 4648에 정의된 표준 Base32 인코딩을 지원하여 플랫폼 간 호환성을 보장합니다. 가볍고 효율적이며, 이진 데이터의 안전하고 인간이 읽을 수 있는 표현이 필요한 애플리케이션에 적합합니다. Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼에서 원활하게 작동합니다.

사용 사례

  • OTP 비밀번호 생성
  • 보안 데이터 인코딩
  • 크로스 플랫폼 토큰 처리
  • 텍스트 저장을 위한 이진 데이터 인코딩
  • Google Authenticator와 같은 OTP 앱과의 상호 운용성

주요 기능

  • RFC 4648 준수
  • 인코딩 및 디코딩 모두를 지원합니다
  • 경량이고 빠름
  • 크로스 플랫폼 호환성
  • OTP 통합을 위한 간단한 API

적합한 대상

  • 이중 인증 앱
  • 보안 자격 증명 저장
  • Base32가 필요한 모바일 및 웹 애플리케이션
  • OTP 프로토콜을 사용하는 개발자
  • 표준화된 텍스트 기반 인코딩이 필요한 응용 프로그램

고려 사항

  • 일반적인 암호화에 적합하지 않습니다
  • 비밀 보안을 수동으로 처리해야 합니다
  • Base32만 지원, 다른 인코딩은 없음
  • 잘못된 입력에 대한 내장된 오류 복구 없음
  • 추가 보안 조치와 함께 사용하는 것이 가장 좋습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Dart

dart-base32

Simple base32 encode/decode following RFC4648. Can handle base32 for OTP secrets also.

Features:

Getting Started

Pubspec

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

dependencies:
  base32: 2.1.3
import 'package:base32/base32.dart';

Start encoding/decoding ...

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

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

API

base32.encode(List<int> byteList, {Encoding encoding = Encoding.standardRFC4648})

Generate and return a RFC4648 base32 string from a list of bytes.

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

Returns String representation of the encoded base32.

base32.encodeHexString(String hex, {Encoding encoding = Encoding.standardRFC4648})

Generate and return a RFC4648 base32 string from a hex string.

  • 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.encodeString(String base32str, {Encoding encoding = Encoding.standardRFC4648})

Generate and return a RFC4648 base32 string from a plain string.

  • base32str - (String) A string intended to be converted to bytes and encoded.

Returns String representation of the encoded base32

Example: Encode a hex string.

base32.encodeString('foobar'); // -> 'MZXW6YTBOI======'
base32.decode(String base32, {Encoding encoding = Encoding.standardRFC4648})

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

import "package:convert/convert.dart"
var decoded = base32.decode("JBSWY3DPEHPK3PXP");
var decodedHex = hex.encode(decoded); // -> '48656c6c6f21deadbeef'
base32.decodeAsHexString(String base32, {Encoding encoding = Encoding.standardRFC4648})

Decodes a base32 string back to its original byte values in hex string format.

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

Returns String of the decoded data.

Example: Decode a base32 string to a hex string.

import "package:convert/convert.dart"
var decoded = base32.decodeAsHexString("JBSWY3DPEHPK3PXP"); // -> '48656c6c6f21deadbeef'
base32.decodeAsString(String base32, {Encoding encoding = Encoding.standardRFC4648})

Decodes a base32 string back to its original byte values.

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

Returns String of the decoded data.

Example: Decode a base32 string to a string.

var decoded = base32.decodeAsString("MZXW6YTBOI======"); // -> 'foobar'
enum Encoding

This is a list of supported variants and their different encodings.

  • StandardRFC4648 - the default standard encoding
    • ABCDEFGHIJKLMNOPQRSTUVWXYZ234567
    • Padded with =
  • base32Hex
    • 0123456789ABCDEFGHIJKLMNOPQRSTUV
    • Padded with =
  • crockford
    • 0123456789ABCDEFGHJKMNPQRSTVWXYZ
    • Not Padded
  • z-base-32
    • ybndrfg8ejkmcpqxot1uwisza345h769
    • Not Padded
  • geohash
    • 0123456789bcdefghjkmnpqrstuvwxyz
    • Padded with =
  • NonStandardRFC4648 - Same as StandardRFC4648, but lowercase, not supported by the spec.
    • abcdefghijklmnopqrstuvwxyz234567
    • Padded with =

Testing

dart test/base32_test.dart

Changelog

See CHANGELOG.md

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트