java8语法糖List<Integer>,List<String>,String之间互转

public class Test {
    public static void main(String[] args) {
        List<Integer> integerList = new ArrayList<>();
        integerList.add(1);
        integerList.add(2);
        integerList.add(3);
        // List<Integer> 转为 List<String>
        List<String> stringList = integerList.stream().map(String::valueOf).collect(Collectors.toList());
        System.out.println("List<Integer> 转为 List<String>=====>" + stringList);

        //List<String> 转为 String 以逗号分隔
        String str = String.join(",", stringList);
        System.out.println("List<String> 转为 String 以逗号分隔====>" + str);

        //List<String> 转为 List<Integer>
        List<Integer> integerList1 = stringList.stream().map(Integer::valueOf).collect(Collectors.toList());
        System.out.println("List<String> 转为 List<Integer>====>" + integerList1);
    }
}

打印结果:

List<Integer> 转为 List<String>=====>[1, 2, 3]
List<String> 转为 String 以逗号分隔====>1,2,3
List<String> 转为 List<Integer>====>[1, 2, 3]

 

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
GMT 0009-2012 SM2 密码算法使用规范,详细描述SM2算法使用规范 GM/T0010-2012 目次 前言 1范围…… 2规范性引用文件…………… 3术语和定义 ·· 4符号和缩略语… 5OID定义… 6基入类型定义…………………… 6.1 Certilicate revocationlists 6.2 Content Encryption AlgorithmIdentifier………………………………………… 6.3 Digest algorithmldentifie 6.4 Digest Encryption algorithmIdentifier…………………… 6.5 Extended certificate OrCertificate 6,6 Extended certificatesAnd certificates……………………… 6,7 Issuer AndserialNumber……………… 6.8 KeyEncryptionAlgorithmldentilier 6,9 Version………………………………………………………………………………… 6.10 Contentinfo 7数据类型data 8签名数据类型 signedData…………… 8.1 signedData类型 8.2 SignerInfo类型…… 9数字信封数据类型 envelopeddata… 9.1 envelopedData类型 9,2 RecipientInfo类型……… 10签名及数字信封数据类型 signed And EnvelopedData……… 11加密数据类型 encryptedData 12密钥协商类型 key AgreementInfo 附录A(规范性附录)SM2密钥格式 A.1椭圆曲线参数语法… A.2公钥语法 A.3私钥语法 参考文献…………………………… GM/T0010-2012 前言 本标准按照GB/T1.12009的规则编写 请注意本文件的某些内容可能涉及专利。本文件的发布机构不承担识别这些专利的责任 本标准由国家密码管理局提出并归口 本标准中的附录A为规范性附录。 木标准起草单位:上海格尔软件股份有限公司、北京海泰方圆科技有限公司、北京数字认证股份有 限公司、无锡江南信息安全工程技术中心、成都卫士通信息产业股份有限公司、上海巾数字证书认证中 心有限公司、兴唐通信科技有限公司、上海颐东网络信息有限公司、山东得安信息技术有限公司、国家信 息安全工程技术研究中心。 本标准起草人:刘平、谭武征、柳増寿、李述胜、徐强、李元正、刘承、王妮娜、夏东山、蒋红宇、孔凡玉 袁峰。 本标准涉及的密码算法按照国家密码管理部门的要求使用 Ⅱ GM/T0010—2012 SM2密码算法加密签名消息语法规范 1范 本规范定义了使用SM2密码算法的加密签名消息语法。 本规范适用于使用SM2密码算法进行加密和签名操作时对操作结果的标准化封装。 2规范性引用文件 下列文件对于本文件的应用是必不可少的。凡是注日期的引用文件,仪注日期的版本适用于本文 件,凡是不注日期的引用文件,其最新版本(包括所有的修改单)适用于本文件。 GM/T0006密码应用标识规范 GM/ T AAAA SV2密码算法使用规范 PKCS #5 Extended-Certificate Syntax 3术语和定义 下列术语适用于本规范。 算法标识 algorithm identifier 用于标明算法机制的数字化信息 SM2算法SM2 algorithM 一种椭圆曲线密杩算法,密钥长度为256比特。 4符号和缩略语 下列缩略语适用于本规范 ECC 椭圆曲线密码算法( Elliptic Curve cryptography) 用户标识( Identity) OID 对象标识符( Object Identity) 5OID定义 本规范对6个对象data, signeddata, envelopedData, signedAnd Data, encryptedData和 key AgreementInfo的标识符进行了定义,详见表1 GM/T0010-2012 表1对象标识符 对象标识符OID 对象标识符定义 1.2,156.10197.6.1.4.2 SM2密码算法加密签名消息语法规范 1.2.156.10197.6.1.4.2.1 数据类型data 1.2.156.10197.6.1.4.2.2 签名数据类型 signedData 1.2,156,10197.6.1.4.2,3 数字信封数据类型 enveloped Data 签名及数字信封数据类型 1.2.156.1C197.6.1.4.2.4 signedAndEnvelopedData 1.2,156,10197.6.1.4.2.5 加密数据类型 encryptedData 1.2,156,10197.6.1.4.2,6 密钥协商类型 key AgreementInfo 6基本类型定义 6.1 Certificate Revocation lists Certificaterevocationlists类型标明一个证书撤销列表的集合。 Certificatereyocationlists;:= SET OF Certificaterevocation list 6. 2 ContentEncryptionAlgorithmldentificr Content Encryptionalgorithmldentifier类型标明一个数据加密算法。其OI见GM/T0006 Content Encryption AlgorithmIdentifier :: AlgorithmIdentifier 6.3 DigestAlgorithm ldentifier DigestAlgorithmIdentifier类型标明一个消息摘要算法,夲规范为SM3算法,其OID见GM/ T0006。 DigestAlgorithmIdentifier : AlgorithmIdentifier 6. 4 DigestEncryptionAlgorithmIdentifier Digest Encryption algorithmIdentifier类型标明一个签名算法,本规范为SM2密码算法,其OI见 GM/T OOO Digest EncryptionAlgorithmIdentifier AlgorithmIdentifier 6.5 ExtendedcertificateorCertificate ExtendedcertificateOrCertificate类型指定一个PKCS#6扩展证书或者一个X.509证书。这一类 型见PKCS=6第6节推荐的语法 ExtendedCertificate OrCertificate ::=CHOICE I certificate Certificate.--.509 extendedCertificate [o IMPLICIT Extended Certificate GM/T0010—2012 6.6 ExtendedCertificates And Certificates ExtendedcertificatesAndcertificates类型指定一个扩展证书和X.509证书的集合。它表示集合足 以包含从可识别的“根”或“顶级CA”到所有签名者的证书链。 ExtendedcertificatesandCertificates : SET OF Extendedcertificate orcertificate 6. Issuer AndSeriaINumber Issuer And SerialNumber类型标明一个证书颁发者可识别名和颁发者确定的证书序列号,可据此 确定一份证书和与此证书对应的实体及公钥。 IssuerAndSerialNumber SEQUENCE issuer name serialNumber certificate SerialNumber 6.8 Kcy EncryptionAlgorithmldentificr KeyEncryptionAlgorithmIdentifier类型标明加密对称密钥的加密算法。 Key encryptionalgorith mldentilier :: Algorithmlden 6.9ⅴ ersion Version类型标明语法版本号。 Version :: INTEGER(1 6. 10 ContentInfo ContentInfo类型标眀内容交换通用语法结构,内容交换的通用语法结构定义如下」 ContentInfo :: SEQUENCE contentType Content type contentO] EXPLICIT ANY DEFINED BY content Type OPTIONAL ContentType OBJECT IDEN TⅠFIER 其中 ContentType内容类型是一个对象标识符,其定义见本规范第5章。 content内容,可选。 7数据类型data data数据类型结构定义如下: Data .. OCTET STRING Data数据类型表示任意的字节串,比如ASCI文本文件。 GM/T0010—2012 8签名数据类型 signed Data 8.1 signed Data类型 signeddata数据类型由任意类型的数据和至少一个签名者的签名值组成。任意类型的数据能够同 时被任意数量的签名者签名。 signeddata数据类型结构定义如下 SignedData ::= SEQUENCE versionⅤ ersion, digest algorithms digest algorithmIc entities. contentInfo sm2signature certificates o IMPLICIT ExtendedCertificates And Certificates OPTIONAL crls[ 1] IMPLICIT Certificate Revocation Lists OPTIONAI Signerinlos Signerinlos Digestalgorithm Identifiers : SET OF Digest AlgorithmIdentifier SignerInfos::= SET OF SignerInfo 结构中各项含义见表2 表2 signedData数据类型 字段名称 数据类型 含义 version (1) V ersion 语法的版木号 digestAlgorithms DigestAlgorithmIdentifiers 消息摘要算法标识符的集合 contention SM2Signaturc 被名的数据内谷,数据类型见GM/ T AAAA ExtendedCertificatesAndcertif certifica PKCS#6扩展证书和X.509证书的集合 Icates CrIs Certificate Revocation lists 证书撤销列表的集合 signIngs SignerInfos 每个签名者信息的集合 8.2 Signerlnfo类型 gnerInfo类型结构定义如下: SignerInfo :: SEQUENCE version version issuer And SerialNumber IssuerAndSerial Number digest Algorithm DigestAlgorithmldentifier authenticated AttributesLO] IMPLICIT Attributes OPTIONAL digest Encryption Algorithm Digest EncryptionAlgorithmIdentifier

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值