From 9f8a7ccc599597f83fe676c688812301ef6c0c10 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 9 Feb 2020 23:30:28 +0800 Subject: [PATCH] add digest, http_test --- digest/digest.dart | 12 ++++++++++++ digest/pubspec.yaml | 5 +++++ http_test/pubspec.yaml | 8 ++++++++ http_test/ss.dart | 13 +++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 digest/digest.dart create mode 100644 digest/pubspec.yaml create mode 100644 http_test/pubspec.yaml create mode 100644 http_test/ss.dart diff --git a/digest/digest.dart b/digest/digest.dart new file mode 100644 index 0000000..6f4fff0 --- /dev/null +++ b/digest/digest.dart @@ -0,0 +1,12 @@ +import 'dart:convert'; +import 'package:crypto/crypto.dart'; + +// https://pub.dev/packages/crypto +main() async { + var bytes = utf8.encode("Hello World!"); + + var digest = sha256.convert(bytes); + + // print("Digest as bytes: ${digest.bytes}"); + print("Digest as hex string: $digest"); +} diff --git a/digest/pubspec.yaml b/digest/pubspec.yaml new file mode 100644 index 0000000..ec679c1 --- /dev/null +++ b/digest/pubspec.yaml @@ -0,0 +1,5 @@ +name: + digest + +dependencies: + crypto: ^2.1.3 diff --git a/http_test/pubspec.yaml b/http_test/pubspec.yaml new file mode 100644 index 0000000..060030c --- /dev/null +++ b/http_test/pubspec.yaml @@ -0,0 +1,8 @@ +name: http_test +description: http test + +dependencies: + http: ^0.12.0+2 + + + diff --git a/http_test/ss.dart b/http_test/ss.dart new file mode 100644 index 0000000..d71e6b9 --- /dev/null +++ b/http_test/ss.dart @@ -0,0 +1,13 @@ +import 'package:http/http.dart' as http; + +main() async { + var url = 'https://hatter.ink/ip/ip.jsonp'; + var response = await http.post(url, body: { + 'name': 'doodle', + 'color': 'blue' + }); + print('Response status: ${response.statusCode}'); + print('Response body: ${response.body}'); + + print(await http.read('https://hatter.ink/ip/ip.jsonp')); +}