Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / gist:35b5a3df05d0e9e4f0a870a769e88571
Created May 7, 2021 11:30 — forked from SFEley/gist:1054553
list all available cucumber steps - (rake cucumber:steps)
# 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
@seanlilmateus
seanlilmateus / git-auto-sign-commits.sh
Created March 31, 2021 20:09 — forked from mort3za/git-auto-sign-commits.sh
Auto sign your git commits
# 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)
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
}
//------------------------------------------------------------------------
// 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 December 21, 2020 09:28 — forked from dhoerl/Asymmetric.swift
Implement asymmetric cryptography for distributed app where keys can both be stored as strings
//
// 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 December 21, 2020 09:26 — forked from akhtarraza/RSAEncryptor.swift
RSA Key-Pair generator with Encryption/Decryption support
//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
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 December 19, 2020 01:38 — forked from pogist/RSAEncryption.swift
Example of RSA encryption on iOS 10+
import Foundation
import Security
struct RSAEncryption {
var publicKey: SecKey!
init(publicKeyString: String) throws {
self.publicKey = try makePublicKey(from: publicKeyString)
}
@seanlilmateus
seanlilmateus / CryptoBridge.swift
Created December 19, 2020 01:34 — forked from dfpalomar/CryptoBridge.swift
Wrapper around swift framework to make it compatible with Kotlin MPP projects
@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 December 17, 2020 12:35 — forked from mislav/aprompt.png
My zsh prompt. No oh-my-zsh needed
aprompt.png