Dart DocumentationcryptoCryptoUtils

CryptoUtils class

Utility methods for working with message digests.

class CryptoUtils {
 /**
  * Convert a list of bytes (for example a message digest) into a hex
  * string.
  */
 static String bytesToHex(List<int> bytes) {
   return _CryptoUtils.bytesToHex(bytes);
 }

 /**
  * Converts a list of bytes into a Base 64 encoded string.
  *
  * The list can be any list of integers in the range 0..255,
  * for example a message digest.
  *
  * If [addLineSeparator] is true, the resulting string will  be
  * broken into lines of 76 characters, separated by "\r\n".
  *
  * If [urlSafe] is true, the result is URL and filename safe.
  *
  * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648)
  *
  */
 static String bytesToBase64(List<int> bytes,
                             {bool urlSafe : false,
                              bool addLineSeparator : false}) {
   return _CryptoUtils.bytesToBase64(bytes,
                                     urlSafe,
                                     addLineSeparator);
 }


 /**
  * Converts a Base 64 encoded String into list of bytes.
  *
  * Decoder ignores "\r\n" sequences from input.
  *
  * Accepts both URL safe and unsafe Base 64 encoded strings.
  *
  * Throws a FormatException exception if input contains invalid characters.
  *
  * Based on [RFC 4648](http://tools.ietf.org/html/rfc4648)
  */
 static List<int> base64StringToBytes(String input) {
   return _CryptoUtils.base64StringToBytes(input);
 }
}

Static Methods

String bytesToHex(List<int> bytes) #

Convert a list of bytes (for example a message digest) into a hex string.

static String bytesToHex(List<int> bytes) {
 return _CryptoUtils.bytesToHex(bytes);
}

String bytesToBase64(List<int> bytes, {bool urlSafe: false, bool addLineSeparator: false}) #

Converts a list of bytes into a Base 64 encoded string.

The list can be any list of integers in the range 0..255, for example a message digest.

If addLineSeparator is true, the resulting string will be broken into lines of 76 characters, separated by "\r\n".

If urlSafe is true, the result is URL and filename safe.

Based on RFC 4648

static String bytesToBase64(List<int> bytes,
                           {bool urlSafe : false,
                            bool addLineSeparator : false}) {
 return _CryptoUtils.bytesToBase64(bytes,
                                   urlSafe,
                                   addLineSeparator);
}

List<int> base64StringToBytes(String input) #

Converts a Base 64 encoded String into list of bytes.

Decoder ignores "\r\n" sequences from input.

Accepts both URL safe and unsafe Base 64 encoded strings.

Throws a FormatException exception if input contains invalid characters.

Based on RFC 4648

static List<int> base64StringToBytes(String input) {
 return _CryptoUtils.base64StringToBytes(input);
}