Skip to content

Please add toHexString to crypto lib #2839

Closed
@sethladd

Description

@sethladd

Now that we have crypto libs appearing (thanks!) I want to ask for toHexString to be added to the crypto library. This is functionality that almost everyone has to write when using hashes like SHA1 or SHA256.

In fact, this function is copied twice in the tests for crypto:

http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/tests/lib/crypto/sha256_test.dart?spec=svn7145&r=7145

http://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/tests/lib/crypto/sha1_test.dart?spec=svn7145&r=7145

Here's the function:

String digestToString(List<int> digest) {
  var buf = new StringBuffer();
  for (var part in digest) {
    buf.add("${(part < 16) ? "0" : ""}${part.toRadixString(16).toLowerCase()}");
  }
  return buf.toString();
}

Please add this directly to the crypto library. Developers will thank you! :)

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.type-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions