Skip to content

Instantly share code, notes, and snippets.

import UIKit
import Security
class RSA: NSObject {
private var publicKey : SecKey?
private var privateKey : SecKey?
func generateKeyPair(keySize: UInt, privateTag: String, publicTag: String) -> Bool {
let publicKeyParameters: [NSString: AnyObject] = [kSecAttrIsPermanent: true as AnyObject,kSecAttrApplicationTag: publicTag as AnyObject]
let privateKeyParameters: [NSString: AnyObject] =[kSecAttrIsPermanent: true as AnyObject,
kSecAttrApplicationTag: publicTag as AnyObject]
let parameters: [String: AnyObject] = [kSecAttrKeyType as String: kSecAttrKeyTypeRSA,kSecAttrKeySizeInBits as String: keySize as AnyObject,kSecPrivateKeyAttrs as String: privateKeyParameters as AnyObject,kSecPublicKeyAttrs as String: publicKeyParameters as AnyObject]
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:04
abgwtp2
struct ContentView: View {
@State private var rect: CGPoint = CGPoint()
var body: some View {
ZStack {
Text("Hello World").background(InsideView(rect: $rect)).onTapGesture {
print("geometry ",self.rect)
}
Circle()
.fill(Color.yellow)
.frame(width: 10, height: 10, alignment: .center)
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:07
abgwtp3
struct ContentView: View {
@State private var rect: CGPoint = CGPoint()
@State private var textText:String = ""
@State private var textValue:String = "Hello World"
var body: some View {
let dropDelegate = TheDropDelegate(textText: $textText)
return VStack {
Spacer()
Text(textValue).background(InsideView(rect: $rect))
.onDrag {
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:09
abgwtp4
struct TheDropDelegate: DropDelegate {
@Binding var textText:String
func validateDrop(info: DropInfo) -> Bool {
return info.hasItemsConforming(to: ["public.utf8-plain-text"])
}
func dropEntered(info: DropInfo) {
print("drop entered")
}
func performDrop(info: DropInfo) -> Bool {
if let item = info.itemProviders(for: "public.utf8-plain-text").first {
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:14
abgwtp5
struct ContentView: View {
@State private var rect: CGPoint = CGPoint()
@State private var textText = ["",""]
@State private var textID = 0
@State private var textValue:String = "Hello World"
var body: some View {
let dropDelegate = TheDropDelegate(textID: $textID, textText: $textText, textValue: $textValue)
return VStack {
Spacer()
Text(textValue).background(InsideView(rect: $rect))
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:15
abgwtp6
func dropTarget(info: DropInfo) -> Int {
if info.location.x > UIScreen.main.bounds.width / 2 {
return(1)
} else {
return(0)
}
}
func performDrop(info: DropInfo) -> Bool {
textID = dropTarget(info: info)
if let item = info.itemProviders(for: ["public.utf8-plain-text"]).first {
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:17
abgwtp7
import SwiftUI
import CoreServices
struct ContentView: View {
@State private var rect:[CGRect] = []
@State private var textText = ["","","",""]
@State private var textID = 0
@State private var textValue1:String = "Hello World 1"
@State private var textValue2:String = "Hello World 2"
var body: some View {
let dropDelegate = TheDropDelegate(textID: $textID, textText: $textText, rect: $rect)
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:19
abgwtp8
func dropTarget(info: DropInfo) -> Int? {
for squareno in 0..<rect.count {
if rect[squareno].contains(info.location) {
return squareno
}
}
return nil
}
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:20
abgwtp9
let dropDelegate = TheDropDelegate(textText: $textText, textValue: $textValue)
struct TheDropDelegate: DropDelegate {
@Binding var textText:String
@Binding var textValue:String
func dropUpdated(info: DropInfo) -> DropProposal? {
print("drop Updated")
self.textValue = ""
return nil
}
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:30
abgwtpA
import SwiftUI
import CoreServices
struct Fonts {
static func futuraCondensedMedium(size:CGFloat) -> Font{
return Font.custom("Futura-CondensedMedium",size: size)
}
}
let backgrounds = [Color.red,Color.blue,Color.orange,Color.green]
struct ContentView: View {
@State private var rect:[CGRect] = []