Skip to content

Instantly share code, notes, and snippets.

@seanlilmateus
seanlilmateus / gist:35b5a3df05d0e9e4f0a870a769e88571
Created May 7, 2021 — forked from SFEley/gist:1054553
list all available cucumber steps - (rake cucumber:steps)
View gist:35b5a3df05d0e9e4f0a870a769e88571
# From https://gist.github.com/778535
# In turn based on http://www.natontesting.com/2010/01/11/updated-script-to-list-all-cucumber-step-definitions/
desc "List all available steps"
task :steps do
require 'hirb'
extend Hirb::Console
features_dir = "features"
step_candidates = Dir.glob(File.join(features_dir,'**/*.rb'))
# Follow all the gem requires, and identify which files have steps in them
View git-auto-sign-commits.sh
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
View DataCrypto.swift
protocol Randomizer {
static func randomIv() -> Data
static func randomSalt() -> Data
static func randomData(length: Int) -> Data
}
protocol Crypter {
func encrypt(_ digest: Data) throws -> Data
func decrypt(_ encrypted: Data) throws -> Data
}
View advanced-swiftui-animations.swift
//------------------------------------------------------------------------
// The SwiftUI Lab: Advanced SwiftUI Animations
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths)
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect)
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier)
//------------------------------------------------------------------------
import SwiftUI
struct ContentView: View {
@seanlilmateus
seanlilmateus / Asymmetric.swift
Created Dec 21, 2020 — forked from dhoerl/Asymmetric.swift
Implement asymmetric cryptography for distributed app where keys can both be stored as strings
View Asymmetric.swift
//
// Asymmetric.swift
//
// Created by David Hoerl on 12/23/18.
// Copyright © 2018 David Hoerl. All rights reserved.
//
/*
This is the portion you need in the distributed app, which uses the public key that can appear in plain text
*/
@seanlilmateus
seanlilmateus / RSAEncryptor.swift
Created Dec 21, 2020 — forked from akhtarraza/RSAEncryptor.swift
RSA Key-Pair generator with Encryption/Decryption support
View RSAEncryptor.swift
//Reference: https://stackoverflow.com/questions/53906275/rsa-public-key-created-in-ios-swift-and-exported-as-base64-not-recognized-in-jav
import SwiftyRSA
class RSAKeyEncoding: NSObject {
// ASN.1 identifiers
private let kASNBitStringIdentifier: UInt8 = 0x03
private let kASNSequenceIdentifier: UInt8 = 0x30
View cryptocode.swift
func getPublicKey64() -> String? {
var error: UnsafeMutablePointer<Unmanaged<CFError>?>?
let publicK = SecKeyCopyExternalRepresentation(self.publicKey!, error) as Data?
let exportedPublicK = publicK?.base64EncodedString()
print("exported PublicK ",exportedPublicK!)
return exportedPublicK! as String
}
func getPrivateKey64() -> String? {
var error: UnsafeMutablePointer<Unmanaged<CFError>?>?
let privateK = SecKeyCopyExternalRepresentation(self.privateKey!, error) as Data?
@seanlilmateus
seanlilmateus / RSAEncryption.swift
Created Dec 19, 2020 — forked from pogist/RSAEncryption.swift
Example of RSA encryption on iOS 10+
View RSAEncryption.swift
import Foundation
import Security
struct RSAEncryption {
var publicKey: SecKey!
init(publicKeyString: String) throws {
self.publicKey = try makePublicKey(from: publicKeyString)
}
@seanlilmateus
seanlilmateus / CryptoBridge.swift
Created Dec 19, 2020 — forked from dfpalomar/CryptoBridge.swift
Wrapper around swift framework to make it compatible with Kotlin MPP projects
View CryptoBridge.swift
@objc public class CryptoBridge: NSObject {
@objc public func generateKeyPair() -> BKeyPair {
let keyPair = RSA.generateKeyPair(keySize: RSA.KeySize.RSA2048)
return BKeyPair(
privateKey: (keyPair?.privateKey.dataRepresentation())!,
publicKey: (keyPair?.publicKey.dataRepresentation())!
)
}
@seanlilmateus
seanlilmateus / aprompt.png
Created Dec 17, 2020 — forked from mislav/aprompt.png
My zsh prompt. No oh-my-zsh needed