optional

PHP 生成公钥私钥,加密解密,签名验签

拜拜、爱过 提交于 2021-02-20 11:50:11
test_encry.php <? php // 创建私钥,公钥 //create_key(); //要加密内容 $str = "test_str" ; // 加密 $encrypt_str = test_encrypt( $str ); // 解密 $decrypt_str = test_decrypt( $encrypt_str ); // echo $decrypt_str;exit; //签名 $sign_str = sign ( $decrypt_str ); // echo $sign_str;exit; //验签 $res = verify ( $decrypt_str , $sign_str ); var_dump ( $res ); exit (); // 创建秘钥对 function create_key(){ // 配置信息 //配置需要用到环境配置文件 openssl.cnf,这里文件地址如下 $config_path = "D:\ApacheServer\Apache\conf\openssl.cnf" ; $config = array ( "digest_alg" => "sha512", "private_key_bits" => 4096, // 字节数 512 1024 2048 4096 等 ,不能加引号,此处长度与加密的字符串长度有关系

Assigning to an optional variable in swift 3.0 using ? operator returns nil

☆樱花仙子☆ 提交于 2021-02-19 01:55:10
问题 Consider the following code. var a:Int? a? = 10 print(a) Here the variable a isn't getting assigned the value 10. If it is because of the '?' operator, why compiler doesn't show a compilation error?. 回答1: Try this var a:Int? a = 10 print(a) Well... ? (Optional) indicates your variable may contain a nil value while ! (unwrapper) indicates your variable must have a memory (or value) when it is used (tried to get a value from it) at runtime. The main difference is that optional chaining fails

C++17 optional tree, error: invalid use of incomplete type

一笑奈何 提交于 2021-02-16 15:15:36
问题 When I compile a binary tree containing optional types: #include <optional> class BinaryTree { public: BinaryTree(); int value; std::optional<BinaryTree> left,right; }; int main() { return 0; } via g++ -std=c++17 -Wfatal-errors main.cpp I face with this error In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/stl_pair.h:59, from /usr/include/c++/7/utility:70, from /usr/include/c++/7/optional:36, from main.cpp:1: /usr/include/c++/7/type_traits: In

Why does Optional.map make this assignment work?

时间秒杀一切 提交于 2021-02-15 12:07:29
问题 Optional<ArrayList<String>> option = Optional.of(new ArrayList<>()); Optional<ArrayList<?>> doesntWork = option; Optional<ArrayList<?>> works = option.map(list -> list); The first attempted assignment does not compile, but the second one with the map does. It feels like the map shouldn't actually accomplish anything, but for some reason it turns my Optional<ArrayList<String>> into an Optional<ArrayList<?>> . Is there some sort of implicit cast going on? 回答1: If you look into the code of map

Why does Optional.map make this assignment work?

僤鯓⒐⒋嵵緔 提交于 2021-02-15 12:06:46
问题 Optional<ArrayList<String>> option = Optional.of(new ArrayList<>()); Optional<ArrayList<?>> doesntWork = option; Optional<ArrayList<?>> works = option.map(list -> list); The first attempted assignment does not compile, but the second one with the map does. It feels like the map shouldn't actually accomplish anything, but for some reason it turns my Optional<ArrayList<String>> into an Optional<ArrayList<?>> . Is there some sort of implicit cast going on? 回答1: If you look into the code of map

Why does Optional.map make this assignment work?

亡梦爱人 提交于 2021-02-15 12:06:16
问题 Optional<ArrayList<String>> option = Optional.of(new ArrayList<>()); Optional<ArrayList<?>> doesntWork = option; Optional<ArrayList<?>> works = option.map(list -> list); The first attempted assignment does not compile, but the second one with the map does. It feels like the map shouldn't actually accomplish anything, but for some reason it turns my Optional<ArrayList<String>> into an Optional<ArrayList<?>> . Is there some sort of implicit cast going on? 回答1: If you look into the code of map

[Java8教程]Java8新特性进阶集合

心已入冬 提交于 2021-02-14 11:12:50
Java8新特性进阶集合 基于 AOP 抽离方法的重复代码 Java8:当 Lambda 遇上受检异常 Java8:对字符串连接的改进 Java8:Java8 中 Map 接口的新方法 Java8:当 forEach 需要索引 Java8:使用 Optional 处理 null Java8:使用并行流 Java8:自制多糖 switch 推荐 400道——大厂Java选择题 [Java网络系列面试题]常见web攻击有哪些? [Java网络安全系列面试题] GET 和 POST 的区别在哪里? 文末 文章收录至 Github: https://github.com/CoderMerlin/coder-programming Gitee: https://gitee.com/573059382/coder-programming 欢迎 关注 并star~ 来源: oschina 链接: https://my.oschina.net/u/4315935/blog/4187866

Apache Pulsar 源码走读(四)TopicLookup请求处理(二)

青春壹個敷衍的年華 提交于 2021-02-13 21:18:46
我们继续查看Apache Pulsar 的TopicLookup请求处理的逻辑。 上一篇说到实际的核心逻辑是这2行代码 LookupOptions options = LookupOptions.builder() .authoritative(authoritative) .advertisedListenerName(advertisedListenerName) .loadTopicsInBundle(true) // 这里这个条件是true .build(); pulsarService.getNamespaceService().getBrokerServiceUrlAsync(topicName, options) 这里传递的参数将 loadTopicsInBundle 设置了成true。我们看下在处理lookup请求过程中是否有loadtopic的逻辑。 NamespaceService.findBrokerServiceUrl 这个函数我们注意到有 ownershipCache.getOwnerAsync 和 searchForCandidateBroker 这2个地方没有细说 我们先看一下 ownershipCache 。 private CompletableFuture<Optional<LookupResult>> findBrokerServiceUrl(

java9迁移注意事项

穿精又带淫゛_ 提交于 2021-02-13 19:02:05
序 本文主要研究下迁移到java9的一些注意事项。 迁移种类 1、代码不模块化,先迁移到jdk9上,好利用jdk9的api 2、代码同时也模块化迁移 几点注意事项 不可读类 比如sun.security.x509,在java9中归到java.base模块中,但是该模块没有export该package 可以通过运行的时候添加--add-exports java.base/sun.security.x509=ALL-UNNAMED来修改exports设定 内部类 比如sun.misc.Unsafe,原本只想让oracle jdk team来使用,不过由于这些类应用太广泛了,为了向后兼容,java9做了妥协,只是将这些类归到了jdk.unsupported模块,并没有限定其可读性。 ➜ ~ java -d jdk.unsupported jdk.unsupported@9 exports com.sun.nio.file exports sun.misc exports sun.reflect requires java.base mandated opens sun.misc opens sun.reflect 删除的类 java9删除了sun.misc.BASE64Encoder,这种情况只能改用其他api,比如java.util.Base64 classpath vs module

在Ubuntu18.04上安装opencv 3.4.1

﹥>﹥吖頭↗ 提交于 2021-02-13 01:57:25
对于安装opencv有的人一次就成功,而有人安装了N多次才成功。我就是那个安装了N多次的人,每次遇到了很多安装错误,只能通过到网上搜教程资料,解决方法;通过一次次的试错,最终完成了安装。再此提醒第一次安装或则安装失败没有头绪的小伙伴,请注重官方安装教程: https://docs.opencv.org/master/d9/df8/tutorial_root.html 安装环境是:ubuntu 18.04 安装的opencv版本为3.4.1(其他版本也行,安装过程类似) opencv安装的依赖包有: Required Packages GCC 4.4.x or later CMake 2.8.7 or higher Git GTK+2.x or higher, including headers (libgtk2.0-dev) pkg-config Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy) ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev [optional] libtbb2 libtbb-dev [optional]