Crypto++ RSA从字符串读取公私匙

发布时间 2023-06-09 15:36:51作者: DoubleLi

string and StringSource (load):

 
  1.  
    string spki = ...;
  2.  
    StringSource ss(spki, true /*pumpAll*/);
  3.  
     
  4.  
    RSA::PublicKey publicKey;
  5.  
    publicKey.Load(ss);
 

vector and ArraySource (load):

 
  1.  
    vector<byte> spki = ...;
  2.  
    ArraySource as(&spki[0], spki.length(), true /*pumpAll*/);
  3.  
     
  4.  
    RSA::PublicKey publicKey;
  5.  
    publicKey.Load(as);
 

string and StringSink (save)

 
  1.  
    string spki;
  2.  
    StringSink ss(spki);
  3.  
     
  4.  
    RSA::PublicKey publicKey(...);
  5.  
    publicKey.Save(ss);