Coder Social home page Coder Social logo

xzdatadigester's Introduction

XZDataDigester

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Pods directory first.

Requirements

iOS 11.0, Xcode 14.0

Installation

XZDataDigester is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'XZDataDigester'

功能特性

支持 md2、md4、md5、sha1、sha224、sha256、sha384、sha512 摘要算法。

let md5 = XZDataDigester.digest(data, algorithm: .MD5, hexEncoding: .uppercase)
let sha1 = XZDataDigester.digest(data, algorithm: .SHA1, hexEncoding: .uppercase)
let sha256 = XZDataDigester.digest(data, algorithm: .SHA256, hexEncoding: .uppercase)

// 对于 md5 或 sha1 有更简便的拓展方法
let md5 = string.md5
let sha1 = string.sha1

支持多数据合并计算摘要。

let digester = XZDataDigester.init(.MD5);

let array = ["1", "2", "3"]
for item in array {
    digester.add(item)
}
let result = digester.digest() as NSData

let md5 = result.hexEncodedString

可以用来计算大文件的摘要。

let digester = XZDataDigester.init(.MD5);

let file = ...
while !file.EOF {
    let data = file.read() // 每次读取一小部分数据,避免占用太多内存
    digester.add(data)
}
let result = digester.digest() as NSData

let md5 = result.hexEncodedString

Author

Xezun, [email protected]

License

XZDataDigester is available under the MIT license. See the LICENSE file for more info.

xzdatadigester's People

Contributors

xezun avatar

Watchers

 avatar  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.