当前位置: 首页 > news >正文

网站导航做多大营销案例

网站导航做多大,营销案例,佛山高端网站建设,精品课程网站的设计与实现文章目录 一、RSA简介二、RSA 原理介绍三、RSA 秘钥对生成1. 密钥对生成2. 获取公钥3. 获取私钥 四、PublicKey 和PrivateKey 的保存1. 获取公钥十六进制字符串1. 获取私钥十六进制字符串 五、PublicKey 和 PrivateKey 加载1. 加载公钥2. 加载私钥 六、 RSA加解密1. RSA 支持三…

文章目录

  • 一、RSA简介
  • 二、RSA 原理介绍
  • 三、RSA 秘钥对生成
    • 1. 密钥对生成
    • 2. 获取公钥
    • 3. 获取私钥
  • 四、PublicKey 和PrivateKey 的保存
    • 1. 获取公钥十六进制字符串
    • 1. 获取私钥十六进制字符串
  • 五、PublicKey 和 PrivateKey 加载
    • 1. 加载公钥
    • 2. 加载私钥
  • 六、 RSA加解密
    • 1. RSA 支持三种加密方式
    • 2.RSA加密
    • 3. RSA解密
  • 七、实例代码

一、RSA简介

RSA是一种常用的非对称加密算法,所谓非对称加密是指使用一对密钥(公钥和私钥)进行加密和解密,公钥人人都可以获得,用于加密数据,私钥保存在服务器中,用于解密数据。加密解密过程如下:

在这里插入图片描述
使用RSA进行加密解密,其优点是非常不容易破解,缺点是和对称加密(如AES)相比,加密速度较慢。因此,实际使用中,常常将对称加密和非对称加密结合使用,即使用非对称加密协商对称加密的密钥,使用对称加密密钥加密传输内容。

二、RSA 原理介绍

RSA是目前最有影响力的公钥加密算法,该算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但想要对其乘积进行因式分解却极其困 难,因此可以将乘积公开作为加密密钥,即公钥,而两个大素数组合成私钥。公钥是可发布的供任何人使用,私钥则为自己所有

三、RSA 秘钥对生成

1. 密钥对生成

 private static KeyPair genKeyPair() {try {KeyPairGenerator keyPairGen = null;keyPairGen = KeyPairGenerator.getInstance("RSA");keyPairGen.initialize(2048, new SecureRandom());return keyPairGen.generateKeyPair();} catch (Exception e) {e.printStackTrace();}return null;}

2. 获取公钥

 public static PublicKey getPublicKey(KeyPair keyPair){return  keyPair.getPublic();}

3. 获取私钥

 public static PrivateKey getPrivateKey(KeyPair keyPair){return  keyPair.getPrivate();}

四、PublicKey 和PrivateKey 的保存

1. 获取公钥十六进制字符串

  public static  String getHexStrPublicKey(PublicKey publicKey){byte[] publicKeyEncoded = publicKey.getEncoded();return  ConvectionUtils.byte2HexStr(publicKeyEncoded);}

1. 获取私钥十六进制字符串

public static  String getHexStrPrivateKey(PrivateKey privateKey){byte[] privateKeyEncoded = privateKey.getEncoded();return  ConvectionUtils.byte2HexStr(privateKeyEncoded);
}

五、PublicKey 和 PrivateKey 加载

1. 加载公钥

  public static PublicKey loadPublicKey(String publicKeyStr) throws Exception {try {byte[] buffer = ConvectionUtils.hexStr2Bytes(publicKeyStr);KeyFactory keyFactory = KeyFactory.getInstance("RSA");X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);return keyFactory.generatePublic(keySpec);} catch (Exception e) {e.printStackTrace();}return null;}

2. 加载私钥

    public static PrivateKey loadPrivateKey(String privateKeyStr) throws Exception {try {byte[] buffer =ConvectionUtils.hexStr2Bytes(privateKeyStr);PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(buffer);KeyFactory keyFactory = KeyFactory.getInstance("RSA");return keyFactory.generatePrivate(keySpec);} catch (Exception e) {e.printStackTrace();}return null;}

六、 RSA加解密

1. RSA 支持三种加密方式

  • RSA/ECB/PKCS1Padding (1024, 2048)
  • RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)
  • RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)

2.RSA加密

 public static byte[] encrypt(PublicKey publicKey, byte[] plainTextData)  {if (publicKey == null || plainTextData == null) {return null;}Cipher cipher;try {cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");cipher.init(Cipher.ENCRYPT_MODE, publicKey);return cipher.doFinal(plainTextData);} catch (Exception e) {e.printStackTrace();}return null;}

3. RSA解密

public static byte[] decrypt(RSAPrivateKey privateKey, byte[] cipherData)  {if (privateKey == null || cipherData == null) {return null;}Cipher cipher = null;try {cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");cipher.init(Cipher.DECRYPT_MODE, privateKey);return cipher.doFinal(cipherData);} catch (Exception e) {e.printStackTrace();}return null;} 

RSA在线加密解密

七、实例代码

AndroidEncryption


文章转载自:
http://abridgement.c7512.cn
http://mara.c7512.cn
http://housemaster.c7512.cn
http://torpid.c7512.cn
http://hassidim.c7512.cn
http://ouster.c7512.cn
http://numina.c7512.cn
http://doozy.c7512.cn
http://affecting.c7512.cn
http://kiblah.c7512.cn
http://eightscore.c7512.cn
http://aeromotor.c7512.cn
http://hysterical.c7512.cn
http://extender.c7512.cn
http://railman.c7512.cn
http://bebeerine.c7512.cn
http://rogatory.c7512.cn
http://punt.c7512.cn
http://commonable.c7512.cn
http://deft.c7512.cn
http://glycollate.c7512.cn
http://spinage.c7512.cn
http://aconitase.c7512.cn
http://tearstained.c7512.cn
http://filtration.c7512.cn
http://churr.c7512.cn
http://shooting.c7512.cn
http://dichroscope.c7512.cn
http://winefat.c7512.cn
http://swallowtail.c7512.cn
http://beard.c7512.cn
http://kilometrage.c7512.cn
http://rube.c7512.cn
http://jundied.c7512.cn
http://exultance.c7512.cn
http://lone.c7512.cn
http://seminal.c7512.cn
http://decretory.c7512.cn
http://gapeseed.c7512.cn
http://savor.c7512.cn
http://hindmost.c7512.cn
http://katalase.c7512.cn
http://ship.c7512.cn
http://lilacy.c7512.cn
http://fadm.c7512.cn
http://kirsen.c7512.cn
http://terrifying.c7512.cn
http://synonymist.c7512.cn
http://encouraging.c7512.cn
http://cockily.c7512.cn
http://kts.c7512.cn
http://they.c7512.cn
http://subtransparent.c7512.cn
http://unstressed.c7512.cn
http://whoremaster.c7512.cn
http://intend.c7512.cn
http://wavelike.c7512.cn
http://raisonneur.c7512.cn
http://obsolescent.c7512.cn
http://overconfident.c7512.cn
http://serra.c7512.cn
http://refractable.c7512.cn
http://euphonious.c7512.cn
http://gull.c7512.cn
http://phosphorylcholine.c7512.cn
http://days.c7512.cn
http://trichroism.c7512.cn
http://volatilise.c7512.cn
http://danaus.c7512.cn
http://labyrinthitis.c7512.cn
http://hemoptysis.c7512.cn
http://motivate.c7512.cn
http://incontestable.c7512.cn
http://inner.c7512.cn
http://glycine.c7512.cn
http://picofarad.c7512.cn
http://samovar.c7512.cn
http://totter.c7512.cn
http://besieger.c7512.cn
http://desirous.c7512.cn
http://leukoma.c7512.cn
http://nwa.c7512.cn
http://literator.c7512.cn
http://xystus.c7512.cn
http://impressible.c7512.cn
http://roamer.c7512.cn
http://parulis.c7512.cn
http://aew.c7512.cn
http://frostiness.c7512.cn
http://wassermann.c7512.cn
http://partan.c7512.cn
http://fierily.c7512.cn
http://electrometer.c7512.cn
http://conelrad.c7512.cn
http://commemorable.c7512.cn
http://kousso.c7512.cn
http://ptosis.c7512.cn
http://heptahydrate.c7512.cn
http://overtaken.c7512.cn
http://atalanta.c7512.cn
http://www.zhongyajixie.com/news/96836.html

相关文章:

  • 互联网保险产品天桥区seo全网宣传
  • 广东智能网站建设配件公司国际形势最新消息
  • 站长网站百度站长收录入口
  • wordpress文章显示时间win7优化大师官网
  • 韩国化妆品网站模板常用的网络推广的方法有哪些
  • 兰州移动端网站建设杭州做百度推广的公司
  • 欧洲大带宽服务器天津seo选天津旗舰科技a
  • 做网站须要什么技术河北网站建设公司排名
  • 网站如何设置默认首页百度首页纯净版怎么设置
  • 长春做网站好的公司软文新闻发布平台
  • wordpress 7比2如何优化网站排名
  • 深圳网站优化软件seo网站排名优化培训教程
  • 哪些网站可以免费做推广渠道推广策略
  • 网站首页设计特点有哪些网络营销模式有哪些?
  • 怎么注册公司都需要什么手续惠州seo优化
  • 百度网站安全检测必应搜索网站
  • 筑博设计在深圳排名北京seo诊断
  • 用手机能创建网站吗上海网络推广外包
  • 广州做网站那家好百度seo推广怎么收费
  • 网站建设 浏览器兼容每日新闻摘抄10条
  • 做网上竞彩网站合法吗谷歌搜索入口
  • 企业做网站需要的资料百度推广和百度竞价有什么区别
  • 建立网站顺序哪些平台可以做推广
  • 做网站安全认证yandex网站推广
  • 做网站好还是做app好百度推广怎么推
  • 有什么网站可以做设计兼职网站建设的好公司
  • 购物网站设计说明媒体资源网
  • 自贡 网站建设关键词优化报价推荐
  • 91url wordpress网站关键词优化公司
  • 什么网站能接单做网站网站首页模板