• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / webcrypto.dart / 25232696112

01 May 2026 08:53PM UTC coverage: 90.337% (-0.1%) from 90.474%
25232696112

push

github

web-flow
ci: trim browser matrix and cache Android AVD (#266)

3730 of 4129 relevant lines covered (90.34%)

1.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/lib/src/webcrypto/webcrypto.random.dart
1
// Copyright 2020 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
part of 'webcrypto.dart';
16

17
/// Fill [destination] with cryptographically random values.
18
///
19
/// Does not accept a [destination] larger than `65536` bytes, use multiple
20
/// calls to obtain more random bytes.
21
///
22
/// **Example**
23
/// ```dart
24
/// import 'dart:convert' show base64;
25
/// import 'dart:typed_data' show Uint8List;
26
/// import 'package:webcrypto/webcrypto.dart';
27
///
28
/// // Allocated a byte array of 64 bytes.
29
/// final bytes = Uint8List(64);
30
///
31
/// // Fill with random bytes.
32
/// fillRandomBytes(bytes);
33
///
34
/// // Print base64 encoded random bytes.
35
/// print(base64.encode(bytes));
36
/// ```
37
void fillRandomBytes(
1✔
38
  TypedData destination,
39
  // Note: Uint8List and friends all implement TypedData, but dartdoc has a bug
40
  //       where it's not reporting this.
41
) {
42
  // This limitation is given in the Web Cryptography Specification, see:
43
  // https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
44
  if (destination.lengthInBytes > 65536) {
2✔
45
    throw ArgumentError.value(
×
46
      destination,
47
      'destination',
48
      'array of more than 65536 bytes is not allowed',
49
    );
50
  }
51

52
  webCryptImpl.random.fillRandomBytes(destination);
2✔
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc