Skip to content

Commit

Permalink
book: add Nip44.swift snippet
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 27, 2024
1 parent 70b7802 commit 2a5e6c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 14 additions & 0 deletions book/snippets/swift/NostrSnippets/Sources/Nip44.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation
import NostrSDK

func nip44() {
let keys = Keys.generate()

let pk = try PublicKey.fromHex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")

let ciphertext = try nip44Encrypt(secretKey: keys.secretKey(), publicKey: pk, content: "my message", version: Nip44Version.V2)
print("Encrypted: \(ciphertext)");

let plaintext = try nip44Decrypt(secretKey: keys.secret_key(), publicKey: pk, payload: ciphertext)
print("Decrypted: \(plaintext)");
}
6 changes: 0 additions & 6 deletions book/snippets/swift/NostrSnippets/Sources/nip44.swift

This file was deleted.

2 changes: 1 addition & 1 deletion book/src/sdk/nips/44.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TODO
<section>

```swift,ignore
{{#include ../../../snippets/swift/NostrSnippets/Sources/nip44.swift}}
{{#include ../../../snippets/swift/NostrSnippets/Sources/Nip44.swift}}
```

</section>
Expand Down

0 comments on commit 2a5e6c7

Please sign in to comment.