Skip to content

William-Weng/WWHash

Repository files navigation

WWHash

Swift-5.6 iOS-14.0 TAG Swift Package Manager-SUCCESS LICENSE

  • A small tool for calculating Hash values.
  • 計算Hash值的小工具。

WWTypewriterLabel

dependencies: [
    .package(url: "https://github.com/William-Weng/WWHash.git", .upToNextMajor(from: "1.0.0"))
]

Function - 可用函式

函式 功能
encode(string:) 將文字轉成hash值
encode(data:) 將資料轉成hash值

Example - 程式範例

import UIKit
import WWPrint
import WWHash

// MARK: - Hash範例
final class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        printHash()
    }
}

// MARK: - 小工具
private extension ViewController {
    
    /// 列印Hash值
    func printHash() {
        
        let string = "很多人以為雜湊就是加密,但雜湊不是加密! 雜湊不是加密! 雜湊不是加密! 雜湊是因為他的特性很適合來做加密的運算,但真的不等同於加密!"
        let md5 = WWHash.md5.encode(string: string)
        let sha256 = WWHash.sha256.encode(data: string.data(using: .utf8)!)
        
        wwPrint("md5 => \(md5)")
        wwPrint("sha256 => \(sha256)")
    }
}

About

A small tool for calculating Hash values.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages