pem 2.0.5 copy "pem: ^2.0.5" to clipboard
pem: ^2.0.5 copied to clipboard

PEM encoding/decoding of textual keys following RFC 7468, supporting both lax/strict-mode, and certificates chains of concatenated PEM blocks.

example/main.dart

// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:pem/pem.dart';

void main() {
  // Parse private key from PEM string.
  final privateKeydata = PemCodec(PemLabel.privateKey).decode('''
    -----BEGIN PRIVATE KEY-----
    MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgVcB/UNPxalR9zDYAjQIf
    jojUDiQuGnSJrFEEzZPT/92hRANCAASc7UJtgnF/abqWM60T3XNJEzBv5ez9TdwK
    H0M6xpM2q+53wmsN/eYLdgtjgBd3DBmHtPilCkiFICXyaA8z9LkJ
    -----END PRIVATE KEY-----
  ''');

  // Print number of bytes in the key, we could obviously also pass it to
  // another library to use the key.
  print('private key contains ${privateKeydata.length} bytes');
}
20
likes
160
points
49.3k
downloads

Publisher

verified publishergoogle.dev

Weekly Downloads

PEM encoding/decoding of textual keys following RFC 7468, supporting both lax/strict-mode, and certificates chains of concatenated PEM blocks.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#crypto #security #parser #pem

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

petitparser

More

Packages that depend on pem