RSA-PHP解密demo
        #客户端传送过来RSA加密密文 ,经过base64处理
        $eccryptData='CYuV0oXjzOiilbn66HZ6Fm8N6Ad9HpnBIb4uo3KM1OyrZfgo30jVer87vVr7b1Eu48E1eT9RCBJFTdzOTi8NQRY0aPUAVpTvhfn+cGe7U9vpnD7sYIILLc9AqmR+YekDbbxll0onMkkrkQIF8mOZI+2plA49btQUl+5M03p41fCNU7ux5h6UYJojxpWx2/EuFDg/wVRhtN2vAjSZNA7ViummcIrpb7LT7D+jobi/MlkwZTAxvskt9hB3zkwcsUIG6M7CAaigc0Ygj5DPTjMQHL7ll5kVW0EmP7bcHYVE+3lOovvHeOF84Ke3x3EDDwRWrHVuorSL/Kq3VGrxY5Wt4SWAr6Ij7VAP/ZU4d2wvASmZHnzu7f78LDD4bTXMjNGECCLd7MoKa7RzoNgYIBKos+Gl+GbfzmTqZ0irIby7+H8yK4FPHdcUPFAjmYNttnueStztwgN0LrGTo4maPJGHTxheTwQY1rBL/opHz7AStBmA37VuknK1ZqdmsiVY2C3gJ425zrDImvMzhZOLntena2mC7RKszISpggMZwaFTcel3JVsk3j9oeitokvLzKnYgaGhouGyBd7n88Gtd7OTEpxwtRdxISxiz/DBFYpo5MWomYefJFXCsJxZUAoKAnA8iISov1lJ0iBEDdn+wkHIhQErBKfOq87+gkbsY/mQ0xfepFFA4yuDjW38NBMGUx4OW3QTLSTaelW3CVhexL5Bs3wra77GuAXw0r5vYuwTxRLs0igV6E9Ms1ZZoy1aK2ZIvZvCKmmcmZZ0HNwd6LXZJCckvtJJ6XSNgQZeRxcYvZpDV0JJSOr0lgITR8I9ndXtYVWB19rMwQbsjm+clwDbNBPoNa9DcUQQO/UOh5RMnC9/llomUp9/Wm0Yw7DQPxaZxb4TS2silN7ZAsMwH/8IkBDyTL5YPtu2jvKbtGrfpxfuDXyYK/6dwzoifoeAN2PB1ppmMPYeK61mfOVSSco6VhrGrZ6zUrBi1XNZNRyBEtbzUZdGlyybIgcZ3LZKaEBG+Yp5gnRRBS8uECuNtW+0UaK6jIn0kPDGI+yxO6141w4X0ggthxw2Tn45kXNiWmMAL9/Yw4q0OhNBpweIZI/CG4wS5wel3rX80gQK4cJhUyvHv6t/QWXckMuVGQomp4+Kf+If9wVCNhq1ZeBjXN5rNdiJ2ZqXN/8julbIuSXqf0H1ATIHngy8oI/bduY+9YJP5INU/lDrK69lDhDdCtuZpSmbb8oqq7pYmenn4DLzJpC2mRAo+7ygmMJUizNBUIaMPMMMHOPy5MRQCnmhwhV0K7qhzPRa9w13RWUgmpcKkMawzhoig7DrqxjG8osVNm7piGnGkXwTGgzQ8/NtTftqTkREO8mPoRDCxwGwV/IwtDlum2Ba3lQB9l1bI9zRftUHK+sQsKToKMhx6/ZQV9xMU0C8w4uJTScOMCvl2loppO/zGICUhGFfvpTtvQWJdRq2cWDZyVmcYoBdo9s58qN2kaNeeFHAHEg4Cvr0seaWXw+GEnllYbqcrORNYNtO1KRLie4Rs+wjCVYevIS/jVNMB0PkzmzIYe7HuqNYNI+F2IULitPww4RzEuzxgUyNS6/u9vm1Y39d1AIRZcYLPwty1whBmkMzmBxW2gqZbHDcA9tnR9DR+2RV1JfLNiEbZbINRQ5IDaLnjS/HVMyoBU3sRi3PAwqpePXujVNt3yZlDbbscMgZkKX0X69PKd+1P2ULNQ9KrVkr5hs9vFCL6ky5Pmo7B5L1zqUVULJEj0pm/hw6s5YlifCQ4UR6e7t6evnf/KKvkGAuHC3kKQVKTdRwU9JhH+Fx9pESSNXd+sPWC9x7SGW9XssOjkMjrgAhXkRDsRu5eXdF+XdPknLcQVOFZ7cdwnaIRayf60y3RNjIZRtDoB1bzgH/PU5BOdtFPkS/mQUOS9XDRx/TxT0ZQkAbQ7pNUZd4sBeGdpKp4/0vA7k4zeCfBZjsasqL7Woz6Zg3wPXvD7oMxCUxqL3G2oksPwibRMjom91Fq1vKM54t8qTVmANxp20kL7qne3XLKMPOV';
        #私钥 注意不能包含其他空格 或其他占位符
        $private_key='-----BEGIN RSA PRIVATE KE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AKhATyFUvBDE/okpHsLi
bOYhSabYDQv98YBC/+A7QE9eMN+qgMjYY+3WYYAqFzdg3nW0zT7Il17TKFzFNeVI
l6BGNvbCG8YKdqzefMqX8olGEgUAuQl8q4fXzyhuID94X/vveaxq4bPRQGHvAuIa
YkXvbgpYVGVCU5KvcEQnR5EFAoGBAMoZXLpXWLrof3Tva+WF96lgNJ53ai7EJh85
3V2iNTdrpgoOjo1CHlTGP+opFCpdq30Ww152FVUuYruphxM04wNPGwrOaoSxFxCY
7cCIYMRO9Nb4jU51ukiLjn5rF915xpiFymH4MkQL2i4TF3NXl2qpOj+9do1ATmGv
QIIt4PK3AoGAOdo6PVl7RB0/p9om2RGnQu/nKo4s05AdaCoZQsIbJXZXYjLgwy1B
XG4oiyasbIDNgNJPHvn4tYqASoxoatx34ErPA2FzBolDRdZG6K/Oxwp3NoXtqsS4
qsCRuFA3HrxPE3fttvth5WhcxNk9Ipfk8c4DU1MhX5EyDiqBPOQTQPU=
-----END RSA PRIVATE KEY-----';
        
        $pi_key =  openssl_pkey_get_private($private_key);

        $decrypted = "";
        $decodeStr = base64_decode($eccryptData);
        $enArray = str_split($decodeStr, 256);#密文长度len=2048 填写256 , len=1024填写128

        foreach ($enArray as $va) {
            openssl_private_decrypt($va,$decryptedTemp,$pi_key);//私钥解密
            $decrypted .= $decryptedTemp;
        }
        
        #解密明文
        var_dump($decrypted) ;


阅读更多

扫码向博主提问

去开通我的Chat快问

carlos__z

非学,无以致疑;非问,无以广识
想对作者说点什么? 我来说一句

MD5加密解密算法demo

2015年01月29日 5KB 下载

Android RSA加密解密demo

2014年08月23日 1.61MB 下载

RSA加密解密Demo

2016年05月04日 273KB 下载

android用MD5加密解密demo

2016年06月03日 22.75MB 下载

没有更多推荐了,返回首页

不良信息举报

RSA-PHP解密demo

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭