ソースを参照

Merge pull request #990 from MaxenceMottard/update/readme

Updated documentation to use the publicKeyExternalRepresentation method
Marcin Krzyzanowski 2 年 前
コミット
55fa5ed941
1 ファイル変更4 行追加4 行削除
  1. 4 4
      README.md

+ 4 - 4
README.md

@@ -560,10 +560,10 @@ RSA Encryption & Decryption Example
 let alicesPrivateKey = try RSA(keySize: 1024)
     
 // Alice shares her **public** key with Bob
-let alicesPublicKeyData = try alicesPrivateKey.publicKeyDER()
+let alicesPublicKeyData = try alicesPrivateKey.publicKeyExternalRepresentation()
     
 // Bob receives the raw external representation of Alices public key and imports it
-let bobsImportOfAlicesPublicKey = try RSA(rawRepresentation: Data(alicesPublicKeyData))
+let bobsImportOfAlicesPublicKey = try RSA(rawRepresentation: alicesPublicKeyData)
     
 // Bob can now encrypt a message for Alice using her public key
 let message = "Hi Alice! This is Bob!"
@@ -591,10 +591,10 @@ let messageAliceSupports = "Hi my name is Alice!"
 let alicesSignature = try alicesPrivateKey.sign(messageAliceSupports.bytes)
     
 // Alice shares her Public key and the signature with Bob
-let alicesPublicKeyData = try alicesPrivateKey.publicKeyDER()
+let alicesPublicKeyData = try alicesPrivateKey.publicKeyExternalRepresentation()
     
 // Bob receives the raw external representation of Alices Public key and imports it!
-let bobsImportOfAlicesPublicKey = try RSA(rawRepresentation: Data(alicesPublicKeyData))
+let bobsImportOfAlicesPublicKey = try RSA(rawRepresentation: alicesPublicKeyData)
         
 // Bob can now verify that Alice signed the message using the Private key associated with her shared Public key.
 let verifiedSignature = try bobsImportOfAlicesPublicKey.verify(signature: alicesSignature, for: "Hi my name is Alice!".bytes)