GithubHelp home page GithubHelp logo

securityservice's Introduction

SecurityService - An easy way to encrypt/decrypt and hash Data

Build Status CocoaPods Version License Platform

SecurityService

Do you always have trouble trying to implement cryptography? Well, you don't need to worry anymore! In this framework I have created a wrapper on top of one of the most beloved crypto frameworks out there, the CryptoSwift.

Why? Just because I wanted to repeat this setup in many projects and then I have created the SecurityService.

Setup

CocoaPods

If you are using CocoaPods, add this to your Podfile and run pod install.

target 'Your target name' do
    pod 'SecurityService', '~> 1.0'
end

Manual Installation

If you want to add it manually to your project, without a package manager, just copy all files from the Classes folder to your project.

Usage

Creating the Service

To create an instance of the service, you only need to import the framework and instantiate the SecurityService:

import SecurityService
let service = SecurityService()

If you want to have some specific configuration, you can create it like this:

import KeyValueStorage
import SecurityService

service = SecurityService(storage: KeyValueStorage(),
                          cipherKey: "keykeykeykeykeyk",
                          cipherIv: "drowssapdrowssap",
                          hashSalt: "nacllcan",
                          hashIterations: 4096,
                          hashKeyLength: 32,
                          hashVariant: .sha256)

Encrypt/Decrypt

With SecurityService it is very easy to encrypt/decrypt Data, it uses the AES-GCM algorithm and you just need to call it like this:

let source = "some string"
let data = source.data(using: .utf8)!
let encrypted = service.encrypt(data: data)
let decrypted = service.decrypt(data: encrypted!)
let result = String(data: decrypted!, encoding: .utf8)

Hash passwords

You can also hash passwords in order to protect the user's data using the PBKDF2 algorithm:

let password = "something"
let hashPassword = service.hash(password: password)

Cryptography Notice

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See http://www.wassenaar.org/ for more information.

Thanks ๐Ÿ‘

The creation of this framework was possible thanks to these awesome people:

Feedback is welcome

If you notice any issue, got stuck or just want to chat feel free to create an issue. We will be happy to help you.

License

SecurityService is released under the MIT License.

securityservice's People

Contributors

ricardorauber avatar ricardorauber-poatek avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.