Skip to content

idrougge/sha1-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

sha1-swift

What?

An SHA-1 hash implementation in Swift

Usage

  1. Include SHA1.swift in your project
  2. Call a public method:
let hash:String = SHA1.hexString(fromFile: filename)

returns Optional("84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1")

let hash:[Int] = SHA1.hash(fromFile: filename)

returns Optional([2845392438, 1191608682, 3124634993, 2018558572, 2630932637])

let hash = SHA1.hexString(from: "abc")

returns Optional("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")

let hash = SHA1.hexString(from: data)

returns Optional("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D")

Implementation details

  • Implemented as a struct with static methods in order to avoid garbage like
let my_sha1_calculator=SHA1()
my_sha1_calculator.hashFromFile(myfile)
  • Since Swift lacks bignums, the hash digest is returned as either a hexadecimal string or as an array of five ints.

Resources

Check out as well

About

SHA-1 implementation in Swift

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages